create redux action creater from action type
Auto Generate redux actionCreater from flowtype.
$ npm install --save-dev babel-plugin-create-redux-action-func
$ yarn add --dev babel-plugin-create-redux-action-func
In:
// @flow
type ADD_HOGE_TYPE = 'hoge/ADD_HOGE'
type DELETE_HOGE_TYPE = 'hoge/DELETE_HOGE'
type Action = { +type: ADD_HOGE_TYPE } | { +type: DELETE_HOGE_TYPE, +id: number }
Out:
// @flow
import type { Action } from './actionTypes';
import { ADD_HOGE, DELETE_HOGE } from './constants';
export function addHoge(): Action {
return {
type: ADD_HOGE
};
}
export function deleteHoge(id: number): Action {
return {
type: DELETE_HOGE,
id
};
}
{
"plugins": [
"create-redux-action-func"
]
}
MIT © akameco