diff --git a/readme.md b/readme.md index f775a51..25a76ab 100644 --- a/readme.md +++ b/readme.md @@ -65,18 +65,25 @@ export const App = () => { ```haskell type Item = {id :: String, title :: String, description :: String} -data State = StateEmpty | StateErrored Error | StateGotItems (Array Item) -data Action = Init +data State + = StateEmpty + | StateErrored Error + | StateGotItems (Array Item) -renderItem item = div [] [ p [] [text item.title] - , span [className "small"] [text item.description] - ] +data Action = ActionInit + +renderItem item = + div [] [ p [] [text item.title] + , span + [className "small"] + [text item.description] + ] renderApp StateEmpty = p [] [text "Loading..."] renderApp (StateErrored e) = p [className "error"] [text (message e)] renderApp (StateGotItems items) = map renderItem items -action Init = do +action ActionInit = do response <- fetch (URL "/api/item") {method: Get} jsonString <- text response itemsOrError <- readJSON jsonString @@ -87,10 +94,11 @@ action Init = do app = mkComponent { initialState: StateEmpty , render: renderApp - , eval: mkEval ( defaultEval { handleAction = action - , initialize: Just Init - } - ) + , eval: + mkEval ( defaultEval { handleAction = action + , initialize: Just ActionInit + } + ) } ```