MCPcopy
hub / github.com/statelyai/xstate / createMachine

Function createMachine

packages/core/src/createMachine.ts:76–165  ·  view source on GitHub ↗
(
  config: {
    types?: MachineTypes<
      TContext,
      TEvent,
      TActor,
      TAction,
      TGuard,
      TDelay,
      TTag,
      TInput,
      TOutput,
      TEmitted,
      TMeta
    >;
    schemas?: unknown;
  } & MachineConfig<
    TContext,
    TEvent,
    TActor,
    TAction,
    TGuard,
    TDelay,
    TTag,
    TInput,
    TOutput,
    TEmitted,
    TMeta
  >,
  implementations?: InternalMachineImplementations<
    ResolvedStateMachineTypes<
      TContext,
      TEvent,
      TActor,
      TAction,
      TGuard,
      TDelay,
      TTag,
      TEmitted
    >
  >
)

Source from the content-addressed store, hash-verified

74 * to provide machine implementations instead.
75 */
76export function createMachine<
77 TContext extends MachineContext,
78 TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
79 TActor extends ProvidedActor,
80 TAction extends ParameterizedObject,
81 TGuard extends ParameterizedObject,
82 TDelay extends string,
83 TTag extends string,
84 TInput,
85 TOutput extends NonReducibleUnknown,
86 TEmitted extends EventObject,
87 TMeta extends MetaObject,
88 // it's important to have at least one default type parameter here
89 // it allows us to benefit from contextual type instantiation as it makes us to pass the hasInferenceCandidatesOrDefault check in the compiler
90 // we should be able to remove this when we start inferring TConfig, with it we'll always have an inference candidate
91 _ = any
92>(
93 config: {
94 types?: MachineTypes<
95 TContext,
96 TEvent,
97 TActor,
98 TAction,
99 TGuard,
100 TDelay,
101 TTag,
102 TInput,
103 TOutput,
104 TEmitted,
105 TMeta
106 >;
107 schemas?: unknown;
108 } & MachineConfig<
109 TContext,
110 TEvent,
111 TActor,
112 TAction,
113 TGuard,
114 TDelay,
115 TTag,
116 TInput,
117 TOutput,
118 TEmitted,
119 TMeta
120 >,
121 implementations?: InternalMachineImplementations<
122 ResolvedStateMachineTypes<
123 TContext,
124 TEvent,
125 TActor,
126 TAction,
127 TGuard,
128 TDelay,
129 TTag,
130 TEmitted
131 >
132 >
133): StateMachine<

Callers 15

order.test.tsFile · 0.90
deep.test.tsFile · 0.90
stateIn.test.tsFile · 0.90
assert.test.tsFile · 0.90
input.test.tsFile · 0.90
definition.test.tsFile · 0.90
toPromise.test.tsFile · 0.90
id.test.tsFile · 0.90
match.test.tsFile · 0.90
transition.test.tsFile · 0.90
clock.test.tsFile · 0.90

Calls

no outgoing calls

Tested by 8

createCounterMachineFunction · 0.72
createMyMachineFunction · 0.72
createDieHardModelFunction · 0.72
createMachineWithExtrasFunction · 0.68
createChildFunction · 0.68
createSomeMachineFunction · 0.68
createSampleMachineFunction · 0.68
childMachineFunction · 0.68