Hello,

I'm looking for help understanding how subscriptions are supposed to be 
used, and how to solve different problems with them. My questions boil down 
to: how do Elm subscriptions handle changing values?

The clock example in the guide and at elm-lang.org/examples/clock has a 
bug: the second hand is in the wrong position during the first second that 
the program runs. You can see it easily right after you refresh the 
examples page.

There is a concept of the "current time" when subscribing to Time.every, 
but that subscription (and subscriptions in general?) only generates 
messages when that value changes. It's only wrong for a second in the clock 
example, but if you change it to show only minutes, you're in a wrong state 
for an entire minute after the program starts.

I can fix the clock example by adding a Command to `init` to ask for the 
current time when things start up, and I can do this in general for 
subscriptions to time-varying values that need to be available for the 
component's lifetime. Is that the recommended way of dealing with this?

I'm worried about that solution because:

- I have to set up matching commands for most subscriptions. For 
subscriptions that are more complicated (say graphQL queries), this means 
either duplication, or moving the query out away from the `subscripitonto 
be shared.


-- 
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.

Reply via email to