redux-sugar-store

1.0.0 • Public • Published

Build Status GitHub issues GitHub version

redux-sugar-store

Redux store sprinkled with some sugar. The "redux-sugar-store" will get all reducers and create a standart actions ({type ..., payload ...}) with the same name. It will create methods in the store so actions can be dispatched directly like plain functions.

(depending on redux)

Sample usage:

import sugarStore from 'redux-sugar-store';
import { createStore } from 'redux';

const initialState = {};
const reducers = [
      {
        exampleReducer: (state, action) => state
      }, {
        exampleReducer: (state, action) => state
      }, {
        anotherReducer: (state, action) => state
      }
    ];

const store = sugarStore(createStore, initialState, reducers);
export default store;

Dispatching events

store.exampleReducer(payload);

Using connect

mapStoreToProps - will get a store reference in the ListConnected component. So store.exampleReducer(payload); can be called in the component as it can be called outside.

const ListConnected = connect((store) => ({
  user: store.users
}), store.mapStoreToProps)(List);

Package Sidebar

Install

npm i redux-sugar-store

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • aleksandrenko