10 Create action creators in flux standard action format.
14 increment = createAction('INCREMENT', amount => amount)
15 increment = createAction('INCREMENT') // same
19 increment(42) === { type: 'INCREMENT', payload: 42 }
23 // Errors are handled for you:
25 increment(err) === { type: 'INCREMENT', payload: err, error: true }
28 [redux-actions](https://www.npmjs.com/package/redux-actions)
31 ### flux-standard-action
33 A standard for flux action objects. An action may have an `error`, `payload` and `meta` and nothing else.
37 { type: 'ADD_TODO', payload: { text: 'Work it' } }
38 { type: 'ADD_TODO', payload: new Error(), error: true }
41 [flux-standard-action](https://github.com/acdlite/flux-standard-action)
46 Dispatch multiple actions in one action creator.
51 { type: 'INCREMENT', payload: 2 },
52 { type: 'INCREMENT', payload: 3 }
56 [redux-multi](https://github.com/ashaffer/redux-multi)
60 Combines reducers (like *combineReducers()*), but without namespacing magic.
65 (state, action) => state + action.number,
66 (state, action) => state + action.number
69 re(10, { number: 2 }) //=> 14
72 [reduce-reducers](https://www.npmjs.com/package/reduce-reducers)
77 Logs actions to your console.
81 // Nothing to see here
84 [redux-logger](https://github.com/evgenyrodionov/redux-logger)
92 Pass promises to actions. Dispatches a flux-standard-action.
96 increment = createAction('INCREMENT') // redux-actions
97 increment(Promise.resolve(42))
100 [redux-promise](https://github.com/acdlite/redux-promise)
105 Sorta like that, too. Works by letting you pass *thunks* (functions) to `dispatch()`. Also has 'idle checking'.
109 fetchData = (url) => (dispatch) => {
110 dispatch({ type: 'FETCH_REQUEST' })
112 .then((data) => dispatch({ type: 'FETCH_DONE', data })
113 .catch((error) => dispatch({ type: 'FETCH_ERROR', error })
116 store.dispatch(fetchData('/posts'))
120 // That's actually shorthand for:
121 fetchData('/posts')(store.dispatch)
124 [redux-promises](https://www.npmjs.com/package/redux-promises)
129 Pass side effects declaratively to keep your actions pure.
134 type: 'EFFECT_COMPOSE',
137 payload: {url: '/some/thing', method: 'GET'}
140 steps: [ [success, failure] ]
145 [redux-effects](https://www.npmjs.com/package/redux-effects)
150 Pass "thunks" to as actions. Extremely similar to redux-promises, but has support for getState.
154 fetchData = (url) => (dispatch, getState) => {
155 dispatch({ type: 'FETCH_REQUEST' })
157 .then((data) => dispatch({ type: 'FETCH_DONE', data })
158 .catch((error) => dispatch({ type: 'FETCH_ERROR', error })
161 store.dispatch(fetchData('/posts'))
165 // That's actually shorthand for:
166 fetchData('/posts')(store.dispatch, store.getState)
170 // Optional: since fetchData returns a promise, it can be chained
171 // for server-side rendering
172 store.dispatch(fetchPosts()).then(() => {
173 ReactDOMServer.renderToString(<MyApp store={store} />)
177 [redux-thunk](https://www.npmjs.com/package/redux-thunk)