0.2.0 • Published 8 years ago

redux-ducks v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

redux-ducks

Redux toolset for isolating state as defined by ducks-modular-redux proposal.

Don't use the package in production yet, it's just a proof of concept

State isolation implementation based on ducks-modular-redux proposal.

Usage

The package provides buildDucksReducer. The function takes your original top level reducer as first argument and returns another function which takes N ducks reducers. See example usage in react-redux-ducks example.

import { createStore } from 'redux';
import { buildDucksReducer } from 'redux-ducks';

// This is your plain old top level reducer (for example result of combinReducers function)
const yourTopLevelReducer => (appState, action) => {
  return appState;
};

// Ducks standard reducer as defined in ducks-modular-redux
const ducksReducer = (appState, action) => {
  return appState;
};

const topLevelReducer = buildDucksReducer(yourTopLevelReducer)(ducksReducer, anotherDucksReducer);

const store = createStore(topLevelReducer);

Examples

See examples in react-redux-ducks repo.