I'm wondering when the app model might change.
Specifically, is code like this guaranteed to be correct, or not?
onClick <| UpdateModelVersionMessage (model.version + 1)
That is, between rendering the UI component, and registering and dispatching the event, could something else update the model such that the UpdateModelVersionMessage value is out of date? Javascript's concurrency model makes me believe I'm safe. But is Elm doing or could Elm possibly do something like batching/reordering messages?
I have been informed that, as of 0.18:
The view is rendered asynchronously through requestanimationframe so, no, it's not safe.
But also:
in 0.19, html events will trigger synchronous rerenders, so that will not be a problem
And finally:
Requestanimationframe runs at 60fps, tho, so the window for events to be sent with an outdated model is really small
i.e. 16ms at most, assuming your view can render within a single frame (if it can't, that's a different issue)
So in this case, I'd recommend doing the simplest thing that could possibly work, knowing the odds of it going wrong are very very slim, and knowing that in 0.19, the view can re-render synchronously, preventing this from being an possible issue altogether
Thanks to Ilias (https://github.com/zwilias) for the answers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With