Excellent article! I think it should end up in elm-community documentation.
one small stylistic idea: I like the update in the form I've seen Evan do
it with the Result unpacked
update : Msg -> Model -> ( Model, Cmd Msg )
update action model =
case action of
Show ->
( model, mountCmd )
HandleArtistsRetrieved (Ok artists) ->
( { model ❘ artists = artists }
, Cmd.none
)
HandleArtistsRetrieved (Err err) ->
let _ =
Debug.log "Error retrieving artist" err
in
(model, Cmd.none)
DeleteArtist id ->
( model
, deleteArtist id HandleArtistDeleted
)
HandleArtistDeleted (Ok _) ->
update Show model
HandleArtistDeleted (Err err) ->
let _ =
Debug.log "Error deleting artist" err
in
(model, Cmd.none)
Also, if the errors are identical, a small utility that does the logging
might be in order:
logError : String -> Http.Error -> Model -> (Model, Cmd Msg)
logError info err model =
let _ =
Debug.log info err
in
(model, Cmd.none)
and then
HandleArtistDeleted (Err err) ->
logError "Error deleting artist" err model
On Tue, Nov 29, 2016 at 6:44 PM, 'Rupert Smith' via Elm Discuss <
[email protected]> wrote:
> This write up here is proving very helpful in understanding the new
> elm-lang/http. Has before and after examples showing how code is changed
> between 0.17 and 0.18:
>
> http://rundis.github.io/blog/2016/haskel_elm_spa_part6.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
There is NO FATE, we are the creators.
blog: http://damoc.ro/
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.