Thank you for helping me find that.
I put the lift in a PlatformHelpers.elm file.
Then I added a function to my JsInterop.State
which curries the lift function
liftMe :
({ a | jsInterop : Model } -> Model -> { a | jsInterop : Model })
-> (Msg -> b)
-> Msg
-> { a | jsInterop : Model }
-> ( { a | jsInterop : Model }, Cmd b )
liftMe set fwd =
lift .jsInterop set fwd update
and I can call it from my outer component function like so.
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
JsInterop action ->
JsInterop.State.liftMe (\m x -> { m | jsInterop = x })
JsInterop action model
It will make all my components take a dependency on PlatformHelpers but on
the outer component!
It would've been even more elegant to forgo the setter lambda and be able
to just pass the field we want to update like this
JsInterop.State.liftMe .jsInterop JsInterop action model
But I understand this is not possible in Elm
https://lexi-lambda.github.io/blog/2015/11/06/functionally-updating-record-types-in-elm/
I see that there is something called Focus but it looks like it would
actually be longer than writing (\m x -> { m | jsInterop = x }) in the
first place. As I would have to write setters for each of fields which is
what I am trying to get away from.
Jonathan
--
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.