fsa-meta-extender
v0.0.3
Published
Flux standard action meta extender.
Downloads
3
Maintainers
Readme
fsa-meta-extender
Flux standard action meta extender.
Getting Started
Installation
$ npm install --save fsa-meta-extender
or
$ yarn add fsa-meta-extender
Usage
// meta/index.js
import metaExtenderCreator from 'fsa-meta-extender'
const extraMeta = {
FOO: 'foo'
}
// second argument is meta property name.
export default metaExtenderCreator(extraMeta, 'extraMeta')
// actions/index.js
import mapExtraMeta from './meta'
const FOO = 'FOO'
const fooAction = arg => { type: FOO, payload: arg }
export default mapExtraMeta({ fooAction })
/*
actions.fooAction
=> FOO
actions.fooAction('hello')
=>
{
type: FOO,
payload: 'hello',
meta: {
extraMeta: 'foo'
}
}
*/
or if you use redux-actions
import {createActions} from 'redux-actions'
import mapExtraMeta from './meta'
export default mapExtraMeta(createActions('FOO'))