Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.