This file contains hidden or 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
| update : Action -> Model -> ( Model, Effects Action ) | |
| update action model = | |
| case action of | |
| HandleResponse result -> | |
| case result of | |
| Ok movies -> | |
| ( { model | movies = movies }, Effects.none ) | |
| Err error -> | |
| let |
This file contains hidden or 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
| get : Decoder value -> String -> Task Error value |
This file contains hidden or 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 ) |
This file contains hidden or 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 Action | |
| = Updated (Result Error Response) |
This file contains hidden or 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
| requestUpdate : Effects Action | |
| requestUpdate = | |
| Http.get decoder url -- Task Error Response | |
| |> Task.toResult -- Task never (Result Error Response) | |
| |> Task.map Updated -- Task never Action | |
| |> Effects.task -- Effects Action |
This file contains hidden or 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
| update : Action -> Model -> ( Model, Effects Action ) | |
| update action model = | |
| case action of | |
| Updated result -> | |
| case result of | |
| Ok response -> -- do things | |
| Err error -> -- handle error |
This file contains hidden or 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 Action | |
| = Updated Response | |
| | APIError Error | |
| update : Action -> Model -> ( Model, Effects Action ) | |
| update action model = | |
| case action of | |
| Updated response -> -- do things | |
| APIError error -> | |
| let |
OlderNewer