Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhsu/redux-chainsaw
[EXPERIMENT] redux action creator and reducer namespacer
https://github.com/jhsu/redux-chainsaw
Last synced: 2 days ago
JSON representation
[EXPERIMENT] redux action creator and reducer namespacer
- Host: GitHub
- URL: https://github.com/jhsu/redux-chainsaw
- Owner: jhsu
- Created: 2015-10-03T18:07:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-09T02:33:05.000Z (about 9 years ago)
- Last Synced: 2024-12-20T21:13:12.609Z (3 days ago)
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
This project is current a WIP
# redux-chainsaw
Allows you to specify action creators and reducers in a tree structure. The keys map to
action types.## action tree
```javascript
const actionTree = {
deals: {
default: someActionCreatorFn,
searchFilter: {
default: someOtherActionCreatorFn,
page: someOtherActionCreatorFn
}
}
};const ActionCreators = createActionCreators(actionTree);
// lookup the action creator for 'deals.searchFilter.page'
let actionCreator = lookupActionCreator(ActionCreators, 'deals.searchFilter.page');// once you have the action creator you can dispatch it
store.dispatch(actionCreator(extraParams));
```## reducer tree
```javascript
const reducerTree = {
deals: {
default: dealsReducer,
searchFilter: {
default: searchFilterReducer
}
}
};let finalReducer = combineReducerFromTree(reducerTree);
// calling a reducer with state and action
let action = {type: 'deals.searchFilter.page'}
finalReducer({}, action)// this will call the searchFilterReducer with an action with type 'page'
```