Replicator for `redux-replicate` designed to *synchronously* persist the state of `redux` stores in memory. Useful for universal rendering of replicator query results and optimistic queries.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.babelrc
.gitignore
.npmignore
LICENSE
README.md
package.json
webpack.config.base.js
webpack.config.development.js
webpack.config.production.js

README.md

redux-replicate-memory

npm version npm downloads

Replicator for redux-replicate designed to synchronously persist the state of redux stores in memory. Useful for universal rendering of replicator query results and optimistic queries.

Table of contents

  1. Installation
  2. Usage
  3. Example using react-redux-provide
  4. Example using compose

Installation

npm install redux-replicate-memory --save

Usage

Use with redux-replicate.

Example using react-redux-provide

// src/replication.js

import memory from 'redux-replicate-memory';
import { theme } from './providers/index';

theme.replication = {
  reducerKeys: ['themeName'],
  replicator: memory
};

Example using compose

import { createStore, combineReducers, compose } from 'redux';
import replicate from 'redux-replicate';
import memory from 'redux-replicate-memory';
import reducers from './reducers';

const initialState = {
  wow: 'such storage',
  very: 'cool'
};

const key = 'superCoolStorageUnit';
const reducerKeys = true;
const replicator = memory;
const replication = replicate({ key, reducerKeys, replicator });
const create = compose(replication)(createStore);
const store = create(combineReducers(reducers), initialState);