0.0.1 • Published 7 years ago

redux-typed-action-reducer v0.0.1

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

Redux Typed Action Reducer

introduction

Typescript Redux Reducer Helper.

Example

import TypedReducer from 'redux-typed-action-reducer';
const ASwitch = TypedReducer<boolean>({ ns: 'switch', init: false })({
  set: (b:boolean) => orgState => b,
});

// => (type: 'switch', args: [true])
ASwitch.toggle(true);

// => 'switch::toggle' 
ASwitch.toggle['type'];

// => roughly
// (pr = false, {type, args}) => {
// const actions = {
//  toggle: (arg) => (org) => arg;
// } 
// if (actions[type]) return actions[type](...args)(pr);
// return pr;
// }
ASwitch.reducer