by Animats · 4y ago · 0 comments
This is classically a problem of GUI systems, where you have a large number of interlinked on-screen objects constantly undergoing modification.
- wait for input
- a dispatcher take any input and turn it into a queue of model update actions
- pop queue to perform latest model updates.
- trigger a full tree rendering, passing the new model
- start again
So:
- the model is a dumb static data structure
- the dispatcher is the responsible for model updates and is a single entry point for the data flow
- the UI and the model don't know about each other
That what ELM, react and so on do now. Monodirectional MVC. It's hard to optimize the rendering though, but it's way easier to reason about when concurrency gets high.
I agree the Elm model makes it easy to reason about it.
Just because we pass "the state of the world" each time instead of mutating it, does not mean that we need a full tree rendering. That is an implementation detail.
We can update just the relevant part. If we think of it mostly as pure functions a lot of it is easier to memoize and — for same input — it is possible to return the same output straight away.
And of course, forcing a purely immutable model comes with its own unique challenges.