Overviewβ
mobx-view-modelis a library for integrationMVVMpattern with MobX and React.
Motivationβ
The main goal of this library is to integrate the usage ofMVVMarchitectural pattern withReact
andMobX
reactivity.
A key aspect of this integration is enabling strict isolation between business logic and presentation layers. By enforcing a clear separation throughViewModels, developers can:
- Encapsulate state management and business rules within observableViewModels
- Keep React components focused only on rendering and user interactions
- Eliminate direct dependencies between UI components and domain models
Pros and consβ
Pros:
- More convenient separation of business logic from the presentation layer (React/etc).
- More flexible and seamless integration of the
React
ecosystem withMobX
.
Cons:
- An additional wrapper in the form of the
withViewModel() HOC
, which wraps the component in an extra layer. This wrapper component further encloses the outer component withinobserver()
. - Additional kilobytes for your bundle.
About MVVMβ
MVVMis an architectural pattern in computer software that facilitates the separation of the development of a graphical user interface (GUI; the view)βbe it via a markup language or GUI codeβfrom the development of the business logic or back-end logic (the model) such thatd the view is not dependent upon any specific model platform.