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
- Simplified
- TypeScript
actionFactory = (type) => factory
declare const actionFactory: <
Payload = undefined,
Type extends string = string
>(
actionType: Type
) => Payload extends undefined
? ActionFactory<undefined, Type>
: ActionFactory<Payload, 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.
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' }