Redux Logic is a middleware for Redux applications designed to centralize and organize business logic and side effects. It allows developers to intercept actions and perform asynchronous processing, supporting various JavaScript styles including callbacks, Promises, async/await, and Observables (via RxJS). The current stable version is 5.0.2. Release cadence typically involves minor and patch versions for dependency updates and security fixes, with major versions reserved for significant changes like dropping Node.js version support or altering internal event structures. Key differentiators include its declarative API for common side effect patterns (filtering, cancellation, latest request handling, debouncing, throttling), robust testing support via `redux-logic-test`, simplified server-side rendering, and the ability to dynamically load logic for code-splitting scenarios. It aims to provide a flexible alternative to libraries like Redux Saga and Redux Observable by allowing developers to choose their preferred async programming paradigm within a declarative framework.
npm install redux-logicVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define and integrate a `redux-logic` unit that fetches data, handles success/failure, and supports cancellation and 'take latest' behavior within a Redux store.
Update `monitor$` handlers to access `err` as an object, e.g., `err.message` for the string, or other properties of the error object.
Upgrade your Node.js runtime to version 8.0.0 or higher. The package.json `engines` field specifies `>=8.0.0`.
Ensure that your build pipeline transpiles `redux-logic` (or its UMD output) to ES5 if you need to support older browsers without native ES6 capabilities. For modern browsers or bundler usage, this is generally not an issue.
This is unlikely to affect most applications. For exceptionally large applications, monitor memory usage and consider refactoring or splitting logic bundles if issues arise.
Install `redux` in your project: `npm install redux` or `yarn add redux`.
Ensure you are using correct import syntax for your module type (e.g., `import { createLogic } from 'redux-logic';` for ESM, or `const { createLogic } = require('redux-logic');` for CJS) and that your bundler/TypeScript configuration is set up correctly for module resolution.Ensure you call `createLogicMiddleware` with your logic array, like `applyMiddleware(createLogicMiddleware([myLogic]))`, rather than `applyMiddleware(createLogicMiddleware)`.
Update your `monitor$` handler to properly check if `err` is an `Error` object before accessing its properties, e.g., `error.message` or `error.stack`.