I had asked this question already:
How do I get the current time in Elm?
And answered it by writing my own (now deprecated) variant of start-app:
http://package.elm-lang.org/packages/z5h/time-app/1.0.1
Of course the Elm architecture has since changed, and my old way of doing things no longer works, because there are no signals or Time.timestamp
.
So....
Suppose I build an app with the standard update function signature:
update : Msg -> Model -> (Model, Cmd Msg)
I'd like to timestamp my model with the time at update. One unacceptable almost-solution is to subscribe to Time.every
. Conceptually this is not what I want. This is updating the model with time and also separately updating model with messages.
What I want is to be able to write an update function with signature:
updateWithTime : Msg -> Time -> Model -> (Model, Cmd Msg)
I started trying to solve this by adding some extra messages:
Msg = ... When | NewTime Time
And creating a new command:
timeCmd = perform (\x -> NewTime 0.0) NewTime Time.now
So in any action, I can fire off an extra command to retrieve the time. But this gets messy and out of hand quickly.
Any ideas on how I can clean this up?