Personally, I like the setup for as it is used in the time tracker SPA
They have a separate file (Util.elm) with the following function:
cmdForRoute : Model -> List (Cmd Msg)
(This function is called inside the update function)
It generates a list of Cmd Msg.
inside cmdForRoute, various API functions are called.
The API is in a separate file, with specific functions for certain read or
write calls, like:
fetchProjects : Model -> (Http.Error -> Msg) -> (List Project -> Msg) -> Cmd
fetchProjects model errorMsg msg =
get model "/projects" Decoders.projectsDecoder errorMsg msg
Each of those functions calls a more generic "get" or "put" function, which
does the actual calls to server:
get : Model -> String -> JD.Decoder a -> (Http.Error -> Msg) -> (a -> Msg)
-> Cmd Msg
get model path decoder errorMsg msg =
You received this message because you are subscribed to the Google Groups "Elm
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.