Skip to content

Expose and document the MVVM observer boundary#2311

Closed
woksin wants to merge 3 commits into
mainfrom
feat/mvvm-observer-boundary
Closed

Expose and document the MVVM observer boundary#2311
woksin wants to merge 3 commits into
mainfrom
feat/mvvm-observer-boundary

Conversation

@woksin

@woksin woksin commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Makes the sanctioned MobX observer boundary in Cratis Arc React MVVM explicit, documented, and guarded, so consumer apps stop reaching through the transitive MobX dependency or blanket-wrapping components.

Added

  • Exported observer from @cratis/arc.react.mvvm so a child component that reads view model observables directly can be given its own observer boundary, with guidance in the React MVVM documentation.
  • Added a no-direct-mobx-react-import ESLint rule that flags direct imports from mobx-react / mobx-react-lite and points consumers to @cratis/arc.react.mvvm instead.

Changed

  • The recommended Cratis Arc ESLint config now reports direct mobx-react / mobx-react-lite imports as errors.

woksin added 3 commits June 21, 2026 10:45
withViewModel observes only the render it wraps, so a child that reads observable
view model state directly needs its own observer boundary. Expose observer from the
@cratis/arc.react.mvvm package root with documentation, so consumers wrap a leaf with
it instead of importing from mobx-react/mobx-react-lite directly, and cover the export
with a spec.
Flag direct imports from mobx-react and mobx-react-lite and steer consumers to import
observer from @cratis/arc.react.mvvm instead, keeping the MobX binding an internal
detail. Register the rule in the recommended config and cover it with rule tests.
Explain that withViewModel observes only the component it wraps, recommend passing plain
props to presentational children, show leaf-only observer() for children that must read
view model observables directly, and discourage blanket wrapping and direct mobx-react
imports.
@woksin woksin added the minor label Jun 21, 2026
@github-actions

Copy link
Copy Markdown

NuGet packages for this PR, e.g. Cratis.Arc:
https://github.com/cratis/arc/packages/1655206?version=20.44.2

@woksin

woksin commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #2312, which consolidates this PR and #2310 into a single PR. Closing in favor of #2312.

@woksin woksin closed this Jun 21, 2026
@woksin woksin deleted the feat/mvvm-observer-boundary branch June 21, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant