I prefer to hoist my container message up, so your fixed code block for my
style would be:
```elm
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
JsInterop action ->
let
( interopModel, interopCmd ) =
(JsInterop.State.update JsInterop action
model.jsInterop)
in
( { model | jsInterop = interopModel }
, interopCmd
)
```
Or if you do not mind forcing a specific name on the model to contain it
then you could always pass the model in too to do this:
```elm
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
JsInterop action ->
JsInterop.State.update JsInterop action model
```
Your `JsInterop.State.update` declaration would be something like (I'm on
phone so please excuse terseness and possible something typed wrong):
```
update : (StateMsg -> msg) -> StateMsg -> { model | jsInterop : StateModel
} -> ( model, Cmd msg )
update mapper msg model =
```
I use this pattern quite a lot. As do other big libraries like elm-mdl (if
you want to look up an example)
On Friday, August 12, 2016 at 7:49:22 PM UTC-6, Jonathan Duncan wrote:
>
> I figured out what my problem was
>
> I was swallowing the command message
>
> update : Msg -> Model -> ( Model, Cmd Msg )
> update msg model =
> case msg of
> JsInterop action ->
> ( { model | jsInterop = fst (JsInterop.State.update action
> model.jsInterop) }
> , Cmd.none
> )
>
>
> I fixed it doing this using Cmd.map
>
>
> update : Msg -> Model -> ( Model, Cmd Msg )
> update msg model =
> case msg of
> JsInterop action ->
> let
> updateobj =
> (JsInterop.State.update action model.jsInterop)
> in
> ( { model | jsInterop = fst updateobj }
> , Cmd.map JsInterop (snd updateobj)
> )
>
> Is there a cleaner way to do this?
>
> Thanks
>
--
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.