https://github.com/sergeysova/create-immutable-reducer
https://github.com/sergeysova/create-immutable-reducer
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sergeysova/create-immutable-reducer
- Owner: sergeysova
- License: wtfpl
- Created: 2016-06-13T13:41:44.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-15T13:24:05.000Z (about 10 years ago)
- Last Synced: 2026-05-13T01:41:13.922Z (2 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/create-immutable-reducer
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# create-immutable-reducer
Create a redux reducer from an object of action handling functions, keyed by the actions they handle.
Has validates for Immutable state.
```js
const createReducer = require('create-immutable-reducer');
const { fromJS } = require('immutable');
const initialState = fromJS({
first: 1,
second: 2,
});
module.exports = createReducer({
ACTION_TYPE_CHANGE_FIRST(state, action) {
return state.set('first', action.first);
},
ACTION_TYPE_CHANGE_SECOND(state, { second }) {
return state.set('second', second);
},
}, initialState);
```