Last active
April 8, 2018 01:49
-
-
Save jasondew/e1172220dfbfd98845e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Response | |
= ... | |
type Action | |
= Updated (Maybe Response) | |
decoder : Decoder Response -- implementation elided | |
url : String -- ditto | |
update : Action -> Model -> ( Model, Effects Action ) | |
update action model = | |
case action of | |
Updated maybeResponse -> | |
case maybeResponse of | |
Just response -> -- do things | |
Nothing -> -- /shrug | |
requestUpdate : Effects Action | |
requestUpdate = | |
Http.get decoder url -- Task Error Response | |
|> Task.toMaybe -- Task never (Maybe Response) | |
|> Task.map Updated -- Task never Action | |
|> Effects.task -- Effects Action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment