Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
redux-immutablejs
Advanced tools
redux-immutablejs
Redux & Immutable integration
This is a small library that aims to provide integration tools between Redux & ImmutableJs that fully conforms Redux actions & reducers standards.
Using combineReducers
it is possible to provide createStore
with initial state using Immutable Iterable type, i.e:
import { createStore } from 'redux';
import { combineReducers } from 'redux-immutablejs';
import Immutable from 'immutable';
import * as reducers from './reducers';
const reducer = combineReducers(reducers);
const state = Immutable.fromJS({});
const store = reducer(state);
export default createStore(reducer, store);
Using createReducer
is an optional function that creates a reducer from a collection of handlers. In addition to
getting rid of the switch statement, it also provides the following benefits:
initialState
type is mutated, it will get converted to an immutable type.import { createReducer } from 'redux-immutablejs'
const initialState = Immutable.fromJS({ isAuth: false })
/**
* Reducer domain that handles authentication & authorization.
**/
export default createReducer(initialState, {
[LOGIN]: (state, action) => state.merge({
isAuth: true,
token: action.payload.token
}),
[LOGOUT]: (domain) => domain.merge({
isAuth: false,
current_identity: {},
token: undefined
})
})
If you want to specify the Immutable type to be used for implicit conversion, pass an constructor function at the end:
export default createReducer([], {
[ADD_STUFF]: (state, { stuff }) => state.add(stuff)
}, true, ::Immutable.OrderedSet);
Please note that this is optional and combineReducers
should work just fine if you prefer the old switch
way.
This library doesn't dictate any specific reducer structure.
While redux-immutable
focuses on CRC, this library
provides some conversion middlewares from FSA to CCA
and vise versa. If you feel like going with Redux's vanilla is the right approach, then consider using our library.
FAQs
Redux Immutable facilities
We found that redux-immutablejs 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.