{"library":"redux-hook-middleware","title":"redux-hook-middleware","description":"A Redux middleware that allows registering pre- and post-dispatch hooks for specific action types. Version 0.1.22, likely low or no active releases. It provides functions like registerPrehook, registerPosthook, and unregisterHook to attach callbacks that execute before or after an action is dispatched. The middleware is simple and lightweight, differentiating from saga or thunk by offering a straightforward hook mechanism without generator functions or promises. It is suitable for small to medium Redux applications needing cross-cutting concerns like logging or side effects tied to specific actions.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install redux-hook-middleware"],"cli":null},"imports":["import { registerPrehook } from 'redux-hook-middleware'","import { registerPosthook } from 'redux-hook-middleware'","import { clearHooks } from 'redux-hook-middleware'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport hookMiddleware, { registerPrehook } from 'redux-hook-middleware';\n\nconst initialState = { count: 0 };\nconst reducer = (state = initialState, action) => {\n  switch (action.type) {\n    case 'INCREMENT':\n      return { count: state.count + 1 };\n    default:\n      return state;\n  }\n};\n\nconst store = createStore(reducer, applyMiddleware(hookMiddleware));\n\nregisterPrehook('INCREMENT', (store, action) => {\n  console.log('About to increment, current count:', store.getState().count);\n});\n\nstore.dispatch({ type: 'INCREMENT' }); // logs: About to increment, current count: 0","lang":"javascript","description":"Setup Redux store with hookMiddleware, register a pre-hook for INCREMENT action, and see it log before state update.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}