npm.io
0.0.1 • Published 9 years ago

redux-typed-action-reducer

Licence
MIT
Version
0.0.1
Deps
0
Vulns
0
Weekly
0

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

Keywords