states
states<
Context,States,On,Tagged,Id>(config):Machine<Context,EventsIn<States> |Extract<keyofOn,string>,ValueIn<States>,TagsOf<States,Tagged>>
Declares a machine from XState’s config, with wait for a state that
holds for seconds, and names it by id: its trait dumps, streams and
checkpoints under that name. Declare it once, beside the game’s traits.
Every type comes from the config, the context’s from context, so call
it with no type arguments: one sets the rest to their defaults, which
turns the checks of targets and is off. Type a context field’s value
where it holds more than its first value says, as
context: { holder: null as number | null }.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Context extends MachineContext |
Record<never, never> |
States extends Record<string, StateConfig<Context>> |
Record<string, StateConfig<Context>> |
On extends Record<string, TransitionTarget<Context>> |
Record<never, never> |
Tagged extends boolean |
boolean |
Id extends string |
string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config |
StatesConfig<Context, States, On, Tagged, Id> & NoInfer<CheckTargets<UnknownTargets<States, `#${Id}.${PathsIn<States>}`> | Exclude<TargetsOf<On[keyof On]>, `#${Id}.${PathsIn<States>}` | `.${PathsIn<States>}`>>> |
Returns
Section titled “Returns”Machine<Context, EventsIn<States> | Extract<keyof On, string>, ValueIn<States>, TagsOf<States, Tagged>>