Home

Awesome

mobx-jsonapi-store

JSON API Store for MobX

Deprecation and migration

mobx-jsonapi-store and mobx-collection-store are deprecated in favor of datx - it follows the same concepts, but adds support for MobX 4 and 5, better TypeScript support and more extensibility.

If you're new to the libraries, check out the datx examples and docs.

If you already use mobx-jsonapi-store, check out the migration guide.


Don't need any JSON API specific features? Check out mobx-collection-store.

Can be used with Redux DevTools.

Build Status Test Coverage npm version

Dependency Status devDependency Status Greenkeeper badge

Basic example

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.

Installation

To install, use npm or yarn. The lib has a peer dependency of mobx 2.7.0 or later (including MobX 3) and mobx-collection-store.

npm install mobx-jsonapi-store mobx-collection-store mobx --save
yarn add mobx-jsonapi-store mobx-collection-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!

Migration from v3 to v4

Version 4 has a few breaking changes described in the migration guide.

Getting started

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.

JSON API Spec

mobx-jsonapi-store is 100% compatible with the JSON API v1.0 spec

API reference

License

The MIT License

Credits

mobx-jsonapi-store is maintained and sponsored by Infinum.

<img src="https://infinum.co/infinum.png" width="264">