redux-trivial-actions
v1.2.1
Published
Objectified Flux Standard Action for Redux
Downloads
29
Readme
redux-trivial-actions utility library by Brainbean Apps
Objectified Flux Standard Action for Redux.
Getting Started
Installation
$ npm install --save redux-trivial-actions
or
$ yarn add redux-trivial-actions
Usage
actions.js
import { createTrivialAction } from 'redux-trivial-actions'
export const demoAction = createTrivialAction('DEMO_ACTION')
reducer.js
import { demoAction } from './actions'
const initialState = { demoValue: false }
const reducer = (state = initialState, action) => {
switch (action.type) {
case demoAction.PERFORM:
return { ...state, demoValue: true }
default:
return state
}
}
export default reducer;
component.js
import { demoAction } from './actions'
// ...
dispatch(demoAction.perform())
// or
dispatch(demoAction())
// ...