updux/docs-docsidy/api/modules.md
2024-08-08 09:28:44 -04:00

2.6 KiB

updux / Exports

updux

Classes

Functions

createAction

createAction<P, T>(type): PayloadActionCreator<P, T>

A utility function to create an action creator for the given action type string. The action creator accepts a single argument, which will be included in the action object as a field called payload. The action creator function will also have its toString() overridden so that it returns the action type, allowing it to be used in reducer logic that is looking for that action type.

Type parameters

Name Type
P void
T extends string = string

Parameters

Name Type Description
type T The action type to use for created actions.

Returns

PayloadActionCreator<P, T>

createAction<PA, T>(type, prepareAction): PayloadActionCreator<ReturnType<PA>["payload"], T, PA>

A utility function to create an action creator for the given action type string. The action creator accepts a single argument, which will be included in the action object as a field called payload. The action creator function will also have its toString() overridden so that it returns the action type, allowing it to be used in reducer logic that is looking for that action type.

Type parameters

Name Type
PA extends PrepareAction<any>
T extends string = string

Parameters

Name Type Description
type T The action type to use for created actions.
prepareAction PA -

Returns

PayloadActionCreator<ReturnType<PA>["payload"], T, PA>


withPayload

withPayload<P>(): (input: P) => { payload: P }

Type parameters

Name
P

Returns

fn

▸ (input): Object

Parameters
Name Type
input P
Returns

Object

Name Type
payload P

withPayload<P, A>(prepare): (...input: A) => { payload: P }

Type parameters

Name Type
P P
A extends any[]

Parameters

Name Type
prepare (...args: A) => P

Returns

fn

▸ (...input): Object

Parameters
Name Type
...input A
Returns

Object

Name Type
payload P