mobx-jsonapi-storedeprecated

JSON API Store for MobX

Usage no npm install needed!

<script type="module">
  import mobxJsonapiStore from 'https://cdn.skypack.dev/mobx-jsonapi-store';
</script>

README

mobx-jsonapi-store

JSON API Store for MobX

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.