enforceActions observed-to-always transition in MobX 6 incremental migration
0 reputation · 26 Sept 2024, 17:47 UTC
An incremental MobX migration for a small React application aims to transition from decorator-based observable inference in MobX 5 to the makeAutoObservable API in MobX 6 without service interruption. The precise goal is to preserve observable consistency across coexisting store modules while aligning with MobX 6's configuration boundaries. A key uncertainty involves the enforceActions setting: keeping it at observed maintains backward compatibility but defers runtime checks, whereas switching to always treats mutations outside actions as exceptions, potentially breaking existing code paths. Additionally, makeAutoObservable inference depends on TypeScript and Babel configuration, and shared observable references between MobX 5 and MobX 6 modules can produce double tracking or missed reactions when inference rules diverge. How should the enforceActions configuration be set during incremental migration to balance compatibility with MobX 5 stores and enforcement consistency in MobX 6? What annotations or configuration adjustments prevent double tracking when cross-version store modules reference shared state? Does the opt-in decorator requirement in MobX 6 necessitate a full store rewrite, or can incremental adoption coexist with existing decorator-based definitions?