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

Method getInitialSnapshot

packages/core/src/StateMachine.ts:414–464  ·  view source on GitHub ↗

* Returns the initial `State` instance, with reference to `self` as an * `ActorRef`.

(
    actorScope: ActorScope<
      MachineSnapshot<
        TContext,
        TEvent,
        TChildren,
        TStateValue,
        TTag,
        TOutput,
        TMeta,
        TStateSchema
      >,
      TEvent,
      AnyActorSystem,
      TEmitted
    >,
    input?: TInput
  )

Source from the content-addressed store, hash-verified

412 * `ActorRef`.
413 */
414 public getInitialSnapshot(
415 actorScope: ActorScope<
416 MachineSnapshot<
417 TContext,
418 TEvent,
419 TChildren,
420 TStateValue,
421 TTag,
422 TOutput,
423 TMeta,
424 TStateSchema
425 >,
426 TEvent,
427 AnyActorSystem,
428 TEmitted
429 >,
430 input?: TInput
431 ): MachineSnapshot<
432 TContext,
433 TEvent,
434 TChildren,
435 TStateValue,
436 TTag,
437 TOutput,
438 TMeta,
439 TStateSchema
440 > {
441 const initEvent = createInitEvent(input) as unknown as TEvent; // TODO: fix;
442 const internalQueue: AnyEventObject[] = [];
443 const preInitialState = this._getPreInitialState(
444 actorScope,
445 initEvent,
446 internalQueue
447 );
448 const [nextState] = initialMicrostep(
449 this.root,
450 preInitialState,
451 actorScope,
452 initEvent,
453 internalQueue
454 );
455
456 const { snapshot: macroState } = macrostep(
457 nextState,
458 initEvent as AnyEventObject,
459 actorScope,
460 internalQueue
461 );
462
463 return macroState as SnapshotFrom<this>;
464 }
465
466 public start(
467 snapshot: MachineSnapshot<

Callers 15

reset.test.tsFile · 0.80
types.test.tsxFile · 0.80
store.test.tsFile · 0.80
persistSnapshotFromLogicFunction · 0.80
persistEventFromLogicFunction · 0.80
undoRedoFromLogicFunction · 0.80
resetFromLogicFunction · 0.80
createStoreCoreFunction · 0.80
getInitialSnapshotFunction · 0.80
types.test.tsFile · 0.80
microstep.test.tsFile · 0.80
_initStateMethod · 0.80

Calls 4

_getPreInitialStateMethod · 0.95
createInitEventFunction · 0.90
initialMicrostepFunction · 0.90
macrostepFunction · 0.90

Tested by

no test coverage detected