https://github.com/zerotohero-dev/swop
intelligently creates higher-order reducers that switch on action types
https://github.com/zerotohero-dev/swop
Last synced: 8 days ago
JSON representation
intelligently creates higher-order reducers that switch on action types
- Host: GitHub
- URL: https://github.com/zerotohero-dev/swop
- Owner: zerotohero-dev
- License: mit
- Created: 2018-03-02T04:57:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T21:36:47.000Z (over 8 years ago)
- Last Synced: 2025-02-13T13:05:19.693Z (over 1 year ago)
- Language: JavaScript
- Size: 593 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
I will add more, but just as a quick usage example.
Assume you have actions `ADD_TO_DO`, `REMOVE_TO_DO`, and reducers `addToDo` and `removeToDo`.
Then…
```javascript
import swop from 'swop';
// constants and reducers are defined here.
// Export a higher-order reducer that switches to the reducer that the action maps to
// or defaults to an identity reducer if there’s not matching action.
export default swop({
[ADD_TO_DO]: addToDo,
[REMOVE_TO_DO]: removeToDo
});
```