by sfvisser · 5y ago · 0 comments
As in Elm, I’ve never fully understood why the events emit a value of some message type that gets interpreted into a function from ‘state -> state’ instead of handling with a state transformation directly.
Feels like boilerplate to me. I can see situations where this approach is useful, but should it be the default?
I guess you can always change your message type to ‘a -> a’ and interpret with ‘id’ if you want to.
In Elm, the Model can be updated faster than the DOM. In other words, the view is rendered at the speed of requestAnimationFrame but the model can change in between animation frames. This means that if you handle model changes inside the view you might get out of sync with the model.
Here is a program [1] that shows this problem. If you click "SnapShot" you will sometimes get the same number but sometimes get different numbers.
Writing a lot of react (without redux) I never really miss serializeability and it’s easy to bolt on locally if you need it.
Besides already mentioned ability to serialize messages it also allows to preprocess or filter messages in the parent.