Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
redux-immutable-reducer
Advanced tools
Immutable state enabled reducers for Redux. ImmutableJS is a peer dependency of this project.
npm install --save redux-immutable-reducer
How to get it?
// ES6 Modules
import immutableReducer from 'redux-immutable-reducer'
// CommonJS
var immutableReducer = require('redux-immutable-reducer').default
// UMD
var immutableReducer = window.ReduxImmutableReducer.default
ReduxImmutableReducer solves the issue of using ImmutableJS with Redux. There are a ton of ugly .toJS()
and .fromJS()
calls when using the two together and this allows you to avoid all of it. It also helps keep devtools state clean and readable.
All you have to do to enable it is to wrap your reducer. This will make the state object within your reducer an Immutable object, making it easy to manipulate and keep the data immutable, but then will transform the output state into a regular Javascript datatype for the rest of your application. Here are a few examples.
import immutableReducer from 'redux-immutable-reducer';
const list = [1, 2, 3, 4];
function listReducer(state = list, action) {
switch (action.type) {
case 'UPDATE':
return state.push(action.payload);
default:
return state;
}
}
export default immutableReducer(todoReducer);
import immutableReducer from 'redux-immutable-reducer';
const deepState = { foo: { bar: { baz: 'qux' }}};
export function deepReducer(state = deepState, action) {
switch (action.type) {
case 'UPDATE':
return state.mergeDeep(action.payload);
default:
return state;
}
}
export default immutableReducer(deepReducer);
npm install --save redux-immutable-reducer
MIT
FAQs
Immutable reducer states with Redux.
We found that redux-immutable-reducer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.