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

Function resolveEnqueueActions

packages/core/src/actions/enqueueActions.ts:114–184  ·  view source on GitHub ↗
(
  actorScope: AnyActorScope,
  snapshot: AnyMachineSnapshot,
  args: ActionArgs<any, any, any>,
  actionParams: ParameterizedObject['params'] | undefined,
  {
    collect
  }: {
    collect: CollectActions<
      MachineContext,
      EventObject,
      ParameterizedObject['params'] | undefined,
      EventObject,
      ProvidedActor,
      ParameterizedObject,
      ParameterizedObject,
      string,
      EventObject
    >;
  }
)

Source from the content-addressed store, hash-verified

112}
113
114function resolveEnqueueActions(
115 actorScope: AnyActorScope,
116 snapshot: AnyMachineSnapshot,
117 args: ActionArgs<any, any, any>,
118 actionParams: ParameterizedObject['params'] | undefined,
119 {
120 collect
121 }: {
122 collect: CollectActions<
123 MachineContext,
124 EventObject,
125 ParameterizedObject['params'] | undefined,
126 EventObject,
127 ProvidedActor,
128 ParameterizedObject,
129 ParameterizedObject,
130 string,
131 EventObject
132 >;
133 }
134): BuiltinActionResolution {
135 const actions: any[] = [];
136 const enqueue: Parameters<typeof collect>[0]['enqueue'] = function enqueue(
137 action
138 ) {
139 actions.push(action);
140 };
141 enqueue.assign = (...args) => {
142 actions.push(assign(...args));
143 };
144 enqueue.cancel = (...args) => {
145 actions.push(cancel(...args));
146 };
147 enqueue.raise = (...args) => {
148 // for some reason it fails to infer `TDelay` from `...args` here and picks its default (`never`)
149 // then it fails to typecheck that because `...args` use `string` in place of `TDelay`
150 actions.push((raise as typeof enqueue.raise)(...args));
151 };
152 enqueue.sendTo = (...args) => {
153 // for some reason it fails to infer `TDelay` from `...args` here and picks its default (`never`)
154 // then it fails to typecheck that because `...args` use `string` in place of `TDelay
155 actions.push((sendTo as typeof enqueue.sendTo)(...args));
156 };
157 enqueue.sendParent = (...args) => {
158 actions.push((sendParent as typeof enqueue.sendParent)(...args));
159 };
160 enqueue.spawnChild = (...args) => {
161 actions.push(spawnChild(...args));
162 };
163 enqueue.stopChild = (...args) => {
164 actions.push(stopChild(...args));
165 };
166 enqueue.emit = (...args) => {
167 actions.push(emit(...args));
168 };
169
170 collect(
171 {

Callers

nothing calls this directly

Calls 6

assignFunction · 0.90
cancelFunction · 0.90
spawnChildFunction · 0.90
stopChildFunction · 0.90
emitFunction · 0.90
evaluateGuardFunction · 0.90

Tested by

no test coverage detected