Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustinspecker/redux-immutable-combine-reducers
A Redux combineReducers that returns an Immutable Map
https://github.com/dustinspecker/redux-immutable-combine-reducers
Last synced: 2 days ago
JSON representation
A Redux combineReducers that returns an Immutable Map
- Host: GitHub
- URL: https://github.com/dustinspecker/redux-immutable-combine-reducers
- Owner: dustinspecker
- License: mit
- Created: 2015-12-12T23:04:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-31T21:43:06.000Z (over 7 years ago)
- Last Synced: 2024-10-28T16:56:40.291Z (11 days ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# redux-immutable-combine-reducers
[![NPM version](https://badge.fury.io/js/redux-immutable-combine-reducers.svg)](https://badge.fury.io/js/redux-immutable-combine-reducers) [![Build Status](https://travis-ci.org/dustinspecker/redux-immutable-combine-reducers.svg)](https://travis-ci.org/dustinspecker/redux-immutable-combine-reducers) [![Coverage Status](https://img.shields.io/coveralls/dustinspecker/redux-immutable-combine-reducers.svg)](https://coveralls.io/r/dustinspecker/redux-immutable-combine-reducers?branch=master)[![Code Climate](https://codeclimate.com/github/dustinspecker/redux-immutable-combine-reducers/badges/gpa.svg)](https://codeclimate.com/github/dustinspecker/redux-immutable-combine-reducers) [![Dependencies](https://david-dm.org/dustinspecker/redux-immutable-combine-reducers.svg)](https://david-dm.org/dustinspecker/redux-immutable-combine-reducers/#info=dependencies&view=table) [![DevDependencies](https://david-dm.org/dustinspecker/redux-immutable-combine-reducers/dev-status.svg)](https://david-dm.org/dustinspecker/redux-immutable-combine-reducers/#info=devDependencies&view=table)
> A [Redux combineReducers](http://redux.js.org/docs/api/combineReducers.html) that returns an [Immutable Map](https://facebook.github.io/immutable-js/docs/#/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
```javascript
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'));
// => 0const 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](https://github.com/dustinspecker)