UNPKG

easy-peasy

Version:

Vegetarian friendly state for React

21 lines (17 loc) 526 B
import { actionOnSymbol } from './constants'; export function createActionCreator(def, _r) { function actionCreator(payload) { const action = { type: def.meta.type, payload, config: def.config, }; if (def[actionOnSymbol] && def.meta.resolvedTargets) { payload.resolvedTargets = [...def.meta.resolvedTargets]; } return _r.dispatch(action); } // We bind the types to the creator for easy reference by consumers actionCreator.type = def.meta.type; return actionCreator; }