Skip to content

Type Alias: PlayerFactory<TMachine>

API / @xmachines/play-xstate / PlayerFactory

type PlayerFactory<TMachine> =
undefined extends InputFrom<TMachine>
? (input?, options?) => PlayerActor<TMachine>
: (input, options?) => PlayerActor<TMachine>;

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

The factory function that definePlayer() returns. Each call makes an independent actor instance from the same configuration.

The input argument follows the rule of createActor in XState. If the input of a machine cannot be undefined, the first argument of the factory is necessary. An absent input is then a compile error, and not an actor that starts in an error status with a null initial route.

Type Parameters

Type Parameter
TMachine extends AnyStateMachine