Skip to content

Type Alias: Guard<TContext, TEvent>

API / @xmachines/play-xstate / Guard

type Guard<TContext, TEvent> = (args) => boolean;

Defined in: packages/play-xstate/src/guards/types.ts:12

The standard signature of an XState guard function. A guard receives { context, event }.

Type Parameters

Type ParameterDefault type
TContextRecord<string, unknown>
TEventPlayEvent

Parameters

ParameterTypeDescription
args{ context: TContext; event: TEvent; }The arguments of the guard: the context and the event
args.contextTContextThe current machine context
args.eventTEventThe event that started the evaluation of the guard

Returns

boolean

The boolean value. It tells you if the guard passes

Deprecated

The next major version removes the guard utilities.