transitionHooks
transitionHooks<
FC
>(…entries
:TransitionHookConfig
<FC
>[]): (machine
:FactoryMachine
<FC
>) => () =>void
Defined in: factory-machine-hooks.ts:113
Registers multiple transition hooks for a FactoryMachine. Returns a setup function for the machine.
Usage:
setup(machine)( transitionHooks( { // optional event filters from: "Idle", type: "start", to: "Running", // optional hook functions transition: transitionFn, guard: guardFn, resolveExit: resolveExitFn, before: beforeFn, handle: handleFn, update: updateFn, leave: leaveFn, enter: enterFn, effect: effectFn, notify: notifyFn, after: afterFn, }, // omit `from`, `to`, `type` to match all transitions { effect: globalFn, ...moreHooks }, ...moreConditions ))
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
FC extends FactoryMachineContext <KeyedStateFactory > |
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
…entries | TransitionHookConfig <FC >[] |
Returns
Section titled “Returns”(
machine
:FactoryMachine
<FC
>): () =>void
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
machine | FactoryMachine <FC > |
Returns
Section titled “Returns”():
void
Returns
Section titled “Returns”void
Source
Section titled “Source”Use this to compose multiple transition hooks in a single setup call.
export function transitionHooks<FC extends FactoryMachineContext>( ...entries: TransitionHookConfig<FC>[]) { return (machine: FactoryMachine<FC>) => { return createDisposer( entries.flatMap((entry) => { return transitionHook<FC>(entry)(machine); }) ); };}