Redux helper library to greatly reduce action+reducer definition boilerplate.
Works with sagas, thunks, reselect, etc
Why?
Because much of the redux boilerplate (defining consts, logic in reducers to match actions to reducers, etc) really isn't necessary if you define actions with matching reducers together.
Usage
const todos = /* todos === { actions: { // exposed for access to action creators addTodo, clearTodos } reducer: (state, action) // exposed as the main reducer for each branch} */ const addTodo clearTodos = todosactionsconst washClothesAction = // { type: 'ADD_TODO', text: 'wash clothes' }const foldClothesAction = // { type: 'ADD_TODO', text: 'fold clothes' } let state = state = todos // state === [ 'wash clothes' ]state = todos // state === [ 'wash clothes', 'fold clothes' ]state = todos // state === [ ]
Example (allows multiple actions routing through a shared reducer)
const category = const setCategory setCategoryToBirds = todosactions let state = 'dogs'state = todos // state === 'cats'state = todos // state === 'birds'
Changelog
v1.1.0 - added ability for multiple actions paired to one reducer v1.2.0 - added optional pass-through selector namespacing for use with combined reducers (docs to follow) v1.3.0 - actions and selectors are now automatically mapped onto default return (convenience)