Skip to main content

actionFactory

import { actionFactory } from '@zedux/react'

A factory for creating action factories (yes, a "factory factory").

Example

Live Sandbox
12
const test = actionFactory('test')
const output = test({ some: 'data' })

Signature

actionFactory = (type) => factory
type

Required. A string.

Will be set as the ActionFactory's .type property. Will also be the type property of all action objects created by the returned factory.

Returns

An ActionFactory function. This factory accepts action payloads and returns valid action objects ready to be dispatched to store.dispatch().

The action objects returned by this factory will have their .type and .payload properties set like so:

const action = actionFactory('type')('payload')
action // { type: 'type', payload: 'payload' }

See Also