mobx-view-model 11

Merged
JS
12d ago
+19796-4876

Summary by cubic

Splits mobx-view-model into a framework-agnostic core with React bindings in mobx-view-model-react, adds SolidJS support via a new mobx-view-model-solid package, and migrates docs to docusite with versioned v9/v10 content. The ViewModel lifecycle is hardened to fix React 19 lazy/Suspense duplication and orphaning, and framework contexts are namespaced to support microfrontends.

  • Solid bindings in mobx-view-model-solid (powered by mobx-solid): withViewModel, withPropsViewModel, useCreateViewModel, useViewModel, ViewModelsProvider, OnlyViewModel.
  • React lifecycle: explicit Suspense retry-loop detection; stabilized mount/unmount and staged vs committed disposal; SSR mode for useCreateViewModel; regression tests for React 19 lazy/Suspense.
  • Store/API: define(), create(), connect(), unmount(), generateId() replace the attachment lifecycle; stores support an optional resource data source; automatic global ID generation removed; vm metadata exposes vm.state and vm.data; processRender replaces processViewComponent; payload comparison uses a configurable comparer; the disableWrapping option was removed.
  • React/Solid contexts are namespaced per framework and stay microfrontend-friendly; SSR is supported and tested for both bindings.
  • Docs: migrated to docusite; Solid guides added; new Error #4 (view already wrapped); v9/v10 versioned content.

Migration/Review notes

  • Import React bindings from mobx-view-model-react; keep core types in mobx-view-model. Use mobx-view-model-solid for Solid.
  • Call withViewModel(VM, View, config?) and pass a plain View; do not pre-wrap with observer or React.memo.
  • In custom stores, override create() instead of createViewModel() and provide an ID when customizing the factory flow.
  • Base implementations now always apply MobX annotations; provide a custom annotation function if you previously disabled wrapping.