1.2.0 • Published 3 years ago

redux-stash-async-storage v1.2.0

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

redux-stash

Persist and rehydrate parts or all of your Redux store.

Getting started

Install with your favourite package manager:

npm install --save redux-stash

Usage

import { applyMiddleware, createStore } from 'redux';
import {
  REHYDRATE,
  createStash,
  createStashMiddleware,
  rehydrateStore,
  LocalStorage,
} from 'redux-stash';

const reducer = (state = { foo: '' }, action) => {
  switch (action.type) {
    case REHYDRATE:
      return {
        ...state,
        foo: action.payload.foo
      };
    default:
      return state;
  }
};

const stashMiddleware = createStashMiddleware(
  createStash({
    name: 'foo',
    selector: state => state.foo,
    storage: new LocalStorage('foo'),
  });
);

const store = createStore(rootReducer, applyMiddleware(stashMiddleware));

rehydrateStore(store);
1.2.0

3 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago