redux-caller
v1.2.0
Published
Redux Calls you: Simple Library to have redux reducers call a method on your store
Downloads
9
Maintainers
Readme
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