Action payload type.
Action metadata type.
Stable action type string.
An action creator carrying the supplied type property.
import { createAction } from '@pacote/flux-actions'
import { type Either, tryCatch } from 'fp-ts/lib/Either'
const changeYear = createAction<number>('CHANGE_YEAR')
changeYear(1955) // { type: 'CHANGE_YEAR', payload: 1955, meta: undefined }
changeYear(1955, { test: true })
// { type: 'CHANGE_YEAR', payload: 1955, meta: { test: true } }
const changeYearWithError = createAction<Either<Error, number>>('CHANGE_YEAR')
changeYearWithError(tryCatch(() => Number('1985'), (error) => error as Error))
Creates a typed action creator for a fixed action type.
The returned function accepts a payload and optional metadata. Use
voidpayloads for actions that need no payload; errors should be wrapped in a value such asEitherwhen they are part of the action data. Metadata is stored on themetafield of the action object.