-
Notifications
You must be signed in to change notification settings - Fork 4
Home
JSON API Store for MobX
Don't need any JSON API specific features? Check out mobx-collection-store.
import {Store} from 'mobx-jsonapi-store';
const store = new Store();
const user = store.sync(userResponse); // Assumption: userResponse was received from some API call and it's a valid JSON API response
console.log(user.name); // "John"
For more, check out the Getting started guide.
To install, use npm
or yarn
. The lib has a peer dependency of mobx
3.0.0 or later.
npm install mobx-jsonapi-store mobx --save
yarn add mobx-jsonapi-store mobx
Since the lib is exposed as a set of CommonJS modules, you'll need something like webpack or browserify in order to use it in the browser.
Don't forget to prepare your code for production for better performance!
The main idea behind the library is to have one instance of the store that contains multiple model types. This way, there can be references between models that can handle all use cases, including circular dependencies.
- Setting up networking
- Defining models
- References
- Configuring the store
- Using the store
- Using the network methods
- Persisting data locally
- Redux DevTools
mobx-jsonapi-store is 100% compatible with the JSON API v1.0 spec
The MIT License
mobx-jsonapi-store is maintained and sponsored by Infinum.