Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.06 KB

File metadata and controls

44 lines (35 loc) · 1.06 KB

Getting Started

Install the library

npm install --save referencejs

Update 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: