redux-hook-middleware
A Redux middleware to provide easy hooks on pre/post dispatch.
install
$ npm i redux-hook-middleware -S
usage
// redux setupconst initialState = /* initial state */ const reducer = { /* reducer function logics */ return state }const middlewares = hookMiddlewareconst store = // middleware logic // how does it worksstore // 'prehooked!'
APIs
registerPrehook(type<string>, hook<function>)<symbol>
Register a hook for former middleware chain and return uniq id for the hook.
registerPosthook(type<string>, hook<function>)<symbol>
Register a hook for later middleware chain and return uniq id for the hook.
registerPrehooks(hookObject<object>)<object>
Register hooks for former middleware chain and return uniq id for the hook. Pass an action type as key and a callback or an array of callbacks as value.
registerPosthooks(hookObject<object>)<onject>
Register hooks for later middleware chain and return uniq id for the hook. Pass an action type as key and a callback or an array of callbacks as value.
unregisterHook(id<symbol>)<void>
Unregister the hook with hook id.
clearHooks()<void>
Unregister all the hooks registered.
development
$ git clone https://github.com/kamataryo/redux-hook-middleware.git$ cd redux-hook-middleware$ npm test