redux-actions-generator
v1.0.0
Published
Flux Standard Action type generator for Redux.
Downloads
1
Maintainers
Readme
redux-actions-generator
Flux Standard Action type generator for Redux.
Installation
The npm package provides a CommonJS build for use in Node.js, and with bundlers like Webpack and Browserify. It also includes an ES modules build that works well with Rollup and Webpack2's tree-shaking.
npm install --save redux-actions-generator
or
yarn add redux-actions-generator
Usage
createAction(prefix<string>, actions <Array<string>>)
import createActions from 'redux-actions-generator';
const actions = createActions(
'TODO',
[
'ADD_TODO',
'TOGGLE_TODO',
'SET_VISIBILITY_FILTER',
]
)
expect(actions).to.deep.equal({
ADD_TODO: 'TODO/ADD_TODO',
TOGGLE_TODO: 'TODO/TOGGLE_TODO',
SET_VISIBILITY_FILTER: 'TODO/SET_VISIBILITY_FILTER',
});
Real world example
actions.js
import createActions from 'redux-actions-generator';
const actions = createActions('', [
'ADD_TODO',
'TOGGLE_TODO',
'SET_VISIBILITY_FILTER',
])
export default actions;