Actionz
Small utility for creating Redux ducks.
API
createAction(type: string, payloadCreator: Function)
Builds an actor creator funciton with type
and a payloadCreator
that will receive all arguments passed to the action creator and returns a payload for the action. If no payloadCreator
is provided, the first argument to the action creator will be used as the payload.
Example
const increment = ;console;/* { type: 'INCREMENT' }*/ const incrementBy = ;console;/* { type: 'INCREMENT_BY', payload: 2 }*/ const incrementThenMultiply = ;console;/* { type: 'INCREMENT_THEN_MULTIPLY', payload: { inc: 2, mult: 3 } }*/
createReducer(defaultState: Object, actionHandlers: Object)
Builds a reducer function with defaultState
and actionHandlers
;
Example
const reducer = ;
Check the examples folder for full examples.