The elm person at our company has left and we now have an elm codebase and we just have to learn it. I think I got most of this ticket done but I need to add This code to the Update.elm
:
update : Config parentMsg parentModel -> parentModel -> Msg -> Model -> ( Model, Cmd Msg )
update config parentModel msg model =
case msg of
OnUrlChange url ->
( model
, { location = url }
|> featureapp.syncCmd
)
// etc...
If I'm understanding this is the TypeScript equivalent of:
function update(config, parentModel, msg, model) {
case (msg) {
'OnUrlChange':
return function (url){
// lets pretend an array is a tuple.
return [model, featureapp.syncCmd({location: url})];
}
break;
}
}
I'm trying to add this:
function update(config, parentModel, msg, model) {
case (msg) {
'OnUrlChange':
return function (url: Url.url){
// \/ \/ THIS IS WHAT I WANT TO ADD \/ \/
trackPageNavigation(Url.toString(url));
// lets pretend an array is a tuple.
return [model, featureapp.syncCmd({location: url})];
}
break;
}
}
edit:
As per The Docs,
Each is handed to the runtime at the same time, and since each can perform arbitrary operations in the world, there are no ordering guarantees about the results.
That, does not work because I do not want to return trackPageNavigation
. I want to only return featureapp.syncCmd
. Or maybe I'm misunderstanding what is going on here. I assumed that
OnUrlChange url ->
( model
, { location = url }
|> featureapp.syncCmd
)
is returning a tuple of (model, Cmd Msg)
. Does it not care which one it returns? This is for the Update.elm
.