Skip to content
Snippets Groups Projects
Unverified Commit 0800bbd8 authored by Louis's avatar Louis :fire:
Browse files

browser compatible es6 was making webpack builds fail, do it old style

parent 00475863
Branches master
No related tags found
No related merge requests found
*.log *.log
.idea
\ No newline at end of file
...@@ -73,4 +73,4 @@ The library exports a single function that returns a redux-compatible reducer fu ...@@ -73,4 +73,4 @@ The library exports a single function that returns a redux-compatible reducer fu
``` reducer(initial: Object, handlers: Map<string, Handler>) ``` ``` reducer(initial: Object, handlers: Map<string, Handler>) ```
Where initial is the `initial` router state and `handlers` is a string -> function map of action types to action reducers. Each handler is passed `state` and `action` as parameters, which correspond to the assigned reducer state and the current action (without the `type` property) and should return the new version of state after resolving the action. Simple as that. Where initial is the `initial` router state and `handlers` is a string -> function map of action types to action reducers. Each handler is passed `state` and `action` as parameters, which correspond to the assigned reducer state and the current action and should return the new version of state after resolving the action. Simple as that.
module.exports = function(initial, handlers) { module.exports = function (initial, handlers) {
return function(state = initial, {type, ...action}) { return function (state, action) {
if (handlers.hasOwnProperty(type)) { if (state == null) state = initial
return handlers[type](state, action) if (handlers.hasOwnProperty(action.type)) {
} return handlers[action.type](state, action)
return state }
} return state
}
} }
{ {
"name": "@commander-lol/redux-reducer", "name": "@commander-lol/redux-reducer",
"version": "1.0.0", "version": "1.0.1",
"description": "Remove the boilerplate for creating redux reducers", "description": "Remove the boilerplate for creating redux reducers",
"main": "index.js", "main": "index.js",
"author": "Louis Capitanchik <contact@louiscap.co>", "author": "Louis Capitanchik <contact@louiscap.co>",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment