redux-repatch-creator
Redux enhancer for dispatching reducers
Repatch is just a simplfied Redux, that let you create actions more briefly by dispatching reducers directly.
The redux-repatch library adds this feature to Redux and ships the redux-thunk functionality too.
However if you need to be compatible with the original redux-thunk, then you are looking for this library.
The redux-repatch-creator
wraps the reducers into a redux-like action object.
Installation
npm install --save redux-repatch-creator
How to use
redux-repatch-creator
provides a store enhancer, that is usable at creating the store. This enhancer ensures that you can use regular actions, original thunk
actions and repatch actions together:
const reducer = state = 0 action const store = const setToValue = type: 'SET_TO_VALUE' value // redux actionconst increment = // repatch action store // 42store // 52
Use with other enhancers
const store =
createAction
function
Use without const increment = type: REDUCER state + value
How it works
The repatch
enhancer extends your reducer by a special action type (REDUCER
), that every repatch action contains. The createAction
function creates a { type: REDUCER, reducer }
action object. When this action arrives into the reducer, the reducer considers that is a repatch action, and reduces the whole state by the given reducer
.
Bundles
or the minified bundle:
then
const repatch createAction REDUCER = ReduxRepatchCreator