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

Function getInitialMicrosteps

packages/core/src/transition.ts:97–131  ·  view source on GitHub ↗
(
  machine: T,
  ...[input]: undefined extends InputFrom<T>
    ? [input?: InputFrom<T>]
    : [input: InputFrom<T>]
)

Source from the content-addressed store, hash-verified

95 * This is a pure function that does not execute `actions`.
96 */
97export function getInitialMicrosteps<T extends AnyStateMachine>(
98 machine: T,
99 ...[input]: undefined extends InputFrom<T>
100 ? [input?: InputFrom<T>]
101 : [input: InputFrom<T>]
102): Array<[SnapshotFrom<T>, ExecutableActionsFrom<T>[]]> {
103 const actorScope = createInertActorScope(machine);
104 const initEvent = createInitEvent(input);
105 const internalQueue: AnyEventObject[] = [];
106
107 const preInitialSnapshot = machine._getPreInitialState(
108 actorScope,
109 initEvent,
110 internalQueue
111 );
112
113 const first = initialMicrostep(
114 machine.root,
115 preInitialSnapshot,
116 actorScope,
117 initEvent,
118 internalQueue
119 );
120
121 const { microsteps } = macrostep(
122 first[0],
123 initEvent,
124 actorScope,
125 internalQueue
126 );
127
128 return [first, ...microsteps] as Array<
129 [SnapshotFrom<T>, ExecutableActionsFrom<T>[]]
130 >;
131}
132
133/**
134 * Gets all potential next transitions from the current state.

Callers 1

microstep.test.tsFile · 0.90

Calls 5

createInertActorScopeFunction · 0.90
createInitEventFunction · 0.90
initialMicrostepFunction · 0.90
macrostepFunction · 0.90
_getPreInitialStateMethod · 0.80

Tested by

no test coverage detected