summaryrefslogtreecommitdiff
path: root/lore/Biz/Ibb/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lore/Biz/Ibb/Core.hs')
-rw-r--r--lore/Biz/Ibb/Core.hs24
1 files changed, 21 insertions, 3 deletions
diff --git a/lore/Biz/Ibb/Core.hs b/lore/Biz/Ibb/Core.hs
index 8fd0068..4ec87e3 100644
--- a/lore/Biz/Ibb/Core.hs
+++ b/lore/Biz/Ibb/Core.hs
@@ -17,14 +17,28 @@ type Routes = Home
type Home = View Action
data Model = Model
- { modelUri :: URI
- , people :: [Person]
+ { uri :: URI
+ , people :: WebData [Person]
} deriving (Show, Eq)
+data RemoteData e a
+ = NotAsked
+ | Loading
+ | Failure e
+ | Success a
+ deriving (Show, Eq)
+
+type WebData a = RemoteData MisoString a
+
+init :: URI -> Model
+init u = Model u Loading
+
data Action
= Nop
| ChangeRoute URI
| HandleRoute URI
+ | FetchPeople
+ | SetPeople (WebData [Person])
deriving (Show, Eq)
home :: Model -> View Action
@@ -51,7 +65,11 @@ see m = div_ [ class_ "container mt-5" ]
[ text "Get new book recommendations from the world's influencers in your email." ]
]
]
- , div_ [ class_ "card-columns" ] $ seePerson /@ people m
+ , div_ [ class_ "card-columns" ] $ case people m of
+ NotAsked -> [ text "Initializing..." ]
+ Loading -> [ text "Loading..." ]
+ Failure err -> [ text err ]
+ Success ps -> seePerson /@ ps
]
seePerson :: Person -> View Action