Install the library
npm install --save referencejsUpdate a Plain store
import { createReference, resolveReference, dereference } from 'referencejs';
const jon = {
id: 'user_1',
name: 'John Doe',
email: 'jon@doe.com'
};
const jonRefrence = createReference('auth', 'users', jon.id);
let store = {};
store = resolveReference(store, jonReference, jon);
dereference(store, jonRefrence) === jon;Or use Immutable if that's your jam
import { Map, is } from 'immutable';
import { createReference, resolveReference, dereference } from 'referencejs/immutable';
const jon = Map({
id: 'user_1',
name: 'John Doe',
email: 'jon@doe.com'
});
const jonRefrence = createReference('auth', 'users', jon.id);
let store = Map();
store = resolveReference(store, jonReference, jon);
is(dereference(store, jonRefrence), jon);Next, read What's A Reference for more details or dive right into one of the APIs: