{"id":18736,"library":"redux-timer-middleware","title":"redux-timer-middleware","description":"A simple Redux middleware to periodically dispatch actions. Version 1.0.0, no recent updates. Enables starting and stopping named timers via Redux actions, with optional payload, interval, and end-period. No dependencies beyond Redux. Lightweight compared to more complex saga/observable-based solutions.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/matpaul/redux-timer-middleware","tags":["javascript","redux-timer-middleware","timer","middleware"],"install":[{"cmd":"npm install redux-timer-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add redux-timer-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-timer-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, middleware works with Redux store","package":"redux","optional":false}],"imports":[{"note":"Default export, not named.","wrong":"import { timerMiddleware } from 'redux-timer-middleware'","symbol":"timerMiddleware","correct":"import timerMiddleware from 'redux-timer-middleware'"},{"note":"Named export for action type constant.","wrong":"import START_TIMER from 'redux-timer-middleware'","symbol":"START_TIMER","correct":"import { START_TIMER } from 'redux-timer-middleware'"},{"note":"Named export for action type constant.","wrong":"import STOP_TIMER from 'redux-timer-middleware'","symbol":"STOP_TIMER","correct":"import { STOP_TIMER } from 'redux-timer-middleware'"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport timerMiddleware, { START_TIMER, STOP_TIMER } from 'redux-timer-middleware';\n\nconst reducer = (state = {}, action) => state;\nconst store = createStore(reducer, applyMiddleware(timerMiddleware));\n\n// Start infinite timer dispatching 'TICK' every second\nstore.dispatch({\n  type: START_TIMER,\n  payload: { actionName: 'TICK', timerName: 'myTimer' }\n});\n\n// Later stop it\nstore.dispatch({\n  type: STOP_TIMER,\n  payload: { timerName: 'myTimer' }\n});","lang":"javascript","description":"Shows how to set up redux-timer-middleware, start an infinite timer, and stop it."},"warnings":[{"fix":"Always provide a unique timerName string.","message":"timerName is required for both START_TIMER and STOP_TIMER, but no validation is performed; missing it may cause silent failures.","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Use timerInterval (in ms) to control tick speed; timerPeriod controls number of ticks.","message":"timerPeriod counts ticks, not milliseconds; setting timerPeriod: 10 dispatches actionName 10 times (once per interval) then dispatches `actionName + '_END'`.","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Manually stop all timers before creating a new store or use a cleanup mechanism.","message":"The middleware does not clean up timers on store unsubscribe; may cause memory leaks if store is recreated.","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"import { createStore, applyMiddleware } from 'redux'; createStore(reducer, applyMiddleware(timerMiddleware));","cause":"timerMiddleware is a function, but must be applied with applyMiddleware correctly.","error":"Uncaught TypeError: Cannot read properties of undefined (reading 'apply')"},{"fix":"Ensure payload.actionName is a string like 'MY_ACTION'.","cause":"Missing or non-string actionName in START_TIMER payload.","error":"TypeError: actionName is not a string"},{"fix":"import { START_TIMER } from 'redux-timer-middleware';","cause":"Using named import incorrectly or forgetting to import constants.","error":"Uncaught ReferenceError: START_TIMER is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}