https://github.com/l2silver/redux-retype-actions
https://github.com/l2silver/redux-retype-actions
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/l2silver/redux-retype-actions
- Owner: l2silver
- Created: 2017-03-01T13:44:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T14:51:20.000Z (almost 9 years ago)
- Last Synced: 2025-01-30T08:47:31.305Z (over 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
redux-retype-actions
=====================
Rename action types
[](https://travis-ci.org/l2silver/redux-retype-actions)
## Why
If you use redux-batched-actions with any kind of redux dev tools, the batched actions show up simply as BATCH_ACTION, which doesn't tell you a whole lot about the action. Now you can easily rename a batch action to something more useful. Although this tool works with any kind of action, I can't think of any other use cases outside of batched-actions
```js
npm install --save redux-retype-actions
```
## Usage
```js
import {createStore} from 'redux';
import {batchActions, enableBatching} from 'redux-batched-actions';
import {retypeAction, enableRetyping} from 'redux-retype-actions';
import {createAction} from 'redux-actions';
const doThing = createAction('DO_THING')
const doOther = createAction('DO_OTHER')
function reducer(state, action) {
switch (action.type) {
case 'DO_THING': return 'thing'
case 'DO_OTHER': return 'other'
default: return state
}
}
const store = createStore(enableRetyping(enableBatching(reducer)), initialState)
const doMultipleThings = retypeAction('DO_MULTIPLE_THINGS', batchActions([doThing(), doOther()]))
store.dispatch(doMultipleThings)
```