You could write a “Helper-message” that could look like this:
type Msg =
...
| GetTimeFor (Time.Posix -> Msg)
| SaveToFile String Time.Posix
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
...
GetTimeFor toMsg->
(model, Task.perform toMsg Time.now)
Didn’t check if this compiles, but does it make sense?
you would send the message like GetTimeFor (SaveToFile "hello bro")
I think it’s quite nice that GetTimeFor
is now reusable wherever you may need it!