Skip to content

Redux Calls you: Simple Library to have redux reducers call a method on your store

License

Notifications You must be signed in to change notification settings

djoeman84/redux-caller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Redux Calls you: Simple Library to have redux reducers call a method on your store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published