redux-caller

1.2.0 • Public • Published

Version Build Status MIT license dependencies devDependency Status airbnb code style


Peer Dependencies

Getting Started

npm install redux-caller --save

Usage

import { Record } from 'immutable';
import { createStore } from 'redux'
import { createReducer } from 'redux-caller';
 
const ACTIONS = {
  SET_COUNT: 'COUNTER_STORE__SET_COUNT'
};
 
class CounterStore extends Record({count: 1}) {
  handleAction({type, payload}) {
    switch (type) {
      case ACTIONS.SET_COUNT:
        return this.set('count', payload);
      default:
        return this;
    }
  }
}
 
let store = createStore(createReducer(new CounterStore()));
 
store.dispatch({ type: ACTIONS.SET_COUNT, payload: 2 }) // => CounterStore { count = 2 }
 
store.dispatch({ type: ACTIONS.SET_COUNT, payload: 20 }) // => CounterStore { count = 20 }
 
store.dispatch({ type: ACTIONS.SET_COUNT, payload: 1 }) // => CounterStore { count = 1 }
 

Credits

License

MIT @ Joe Delgado

Package Sidebar

Install

npm i redux-caller

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • el_gato