Socket
Socket
Sign inDemoInstall

redux-immutable-combine-reducers

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    redux-immutable-combine-reducers

A Redux combineReducers that returns an Immutable Map


Version published
Weekly downloads
29
decreased by-51.67%
Maintainers
1
Install size
435 kB
Created
Weekly downloads
 

Readme

Source

redux-immutable-combine-reducers

NPM version Build Status Coverage Status

Code Climate Dependencies DevDependencies

A Redux combineReducers that returns an Immutable Map

Install

npm install --save redux-immutable-combine-reducers

Purpose

To have a root that is also an Immutable Map. Redux's combineReducers works with Immutable, but the root is still a plain object. This utility will return an Immutable Map instead.

Usage

import combineReducers from 'redux-immutable-combine-reducers';
import {Map} from 'immutable';

function counter(state = 0, action = {}) {
  switch (action.type) {
    case 'INCREMENT':
      return state + 1;
    case 'DECREMENT':
      return state - 1;
    default:
      return state;
  }
}

function filter(state = '', action = {}) {
  switch (action.type) {
    case 'SET_FILTER':
      return action.filter;
    default:
      return state;
  }
}

const objReducer = combineReducer({counter, filter});
const objState = objReducer();
console.log(objState.get('counter'));
// => 0

const mapReducer = combineReducer(Map({counter, filter}));
const mapState = mapReducer();
console.log(mapState.get('counter'));
// => 0

API

combineReducers(reducers)

Returns a reducer function that always returns an Immutable.Map.

reducers

Type: object | Immutable.Map

An object or Immutable.Map with all keys or entries being functions.

LICENSE

MIT © Dustin Specker

Keywords

FAQs

Last updated on 03 Mar 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc