4 ms·
MobX re-introduces all push-reactivity problems that React removes.
by sesm 3y ago
MobX re-introduces all push-reactivity problems that React removes.
- machiaweliczny 3y agoIt can do it but not necessarily. I think in strict mode only actions can modify state and if you use reactivity only for rendering then it great
- Rapzid 3y agoCan you elaborate on this? React's in-built reactivity system via props and context are certainly push. I'm not even aware of a pull-based reactivity system.
- sesm 3y agoReact developers wrote about this here: https://legacy.reactjs.org/docs/design-principles.html#scheduling https://legacy.reactjs.org/docs/design-principles.html#sched... Let me try to explain this differently: A typical reactive framework architecture (RX, Knockout, etc) looks like this Events -> Observables -> Computed values -> Subscriptions -> DOM updates It aims to provide a targeted DOM update in response to event as soon as possible, but it has several major disadvantages: 1. Batching and prioritizing capabilities either don't exist, or are limited and generic, in particular by default they are not tied to UI structure, because the framework itself doesn't want to be aware of UI structure, it just wants the framework user to provide event sources and write update targets manually. 2. Computed values are computed if corresponding subscriptions are active. In contrast, React hides state propagation logic inside the component tree, so the computation happens only when components are actually rendered. Issue 1 is not relevant for MobX-React case, because React is doing UI update batching and prioritisation. But issue 2 is very real, especially when using React Router. I had multiple cases where Computed values were computed at unexpected point in time and used observable values that were not initialised, while corresponding React components were not even visible on the screen.