Class ActorState<TState, TPublicContext>

The state of an actor.

This is intended to closely mimic an XState State object.

There are some differences:

  • events are not considered public so we remove _event, event, and events
  • we do not yet have any concept of next events so we remove nextEvents and can
  • actions, activities, and children are removed
  • we do not include history in the public interface
  • meta is considered private for now, so we do not include it
  • the only top-level key of context is public and it includes only the publicContext
  • we do not support changed

Type Parameters

  • TState extends StateValue = any

  • TPublicContext extends Record<string, unknown> = any

Hierarchy

  • ActorState

Constructors

  • Type Parameters

    • TState extends string | {
          [key: string]: components["schemas"]["StateValue"] | undefined;
      } = any

    • TPublicContext extends Record<string, unknown> = any

    Parameters

    • machineState: {
          done: boolean;
          publicContext?: {
              [key: string]: unknown;
          };
          state: string | {
              [key: string]: components["schemas"]["StateValue"] | undefined;
          };
          tags: string[];
          ts: number;
      }
      • done: boolean

        Description

        Is the state machine complete

      • Optional publicContext?: {
            [key: string]: unknown;
        }

        Description

        The public context of the machine instance.

        This includes all context under the public key.

        • [key: string]: unknown
      • state: string | {
            [key: string]: components["schemas"]["StateValue"] | undefined;
        }
      • tags: string[]

        Description

        Array of tags for the current states

      • ts: number

        Description

        Timestamp for when the state was created

    Returns ActorState<TState, TPublicContext>

Properties

context: {
    public: TPublicContext;
}

The context of the instance.

The only key is public and it includes only the publicContext.

Type declaration

  • public: TPublicContext
done: boolean

Has the instance reached a final state?

machineState: {
    done: boolean;
    publicContext?: {
        [key: string]: unknown;
    };
    state: string | {
        [key: string]: components["schemas"]["StateValue"] | undefined;
    };
    tags: string[];
    ts: number;
}

Type declaration

  • done: boolean

    Description

    Is the state machine complete

  • Optional publicContext?: {
        [key: string]: unknown;
    }

    Description

    The public context of the machine instance.

    This includes all context under the public key.

    • [key: string]: unknown
  • state: string | {
        [key: string]: components["schemas"]["StateValue"] | undefined;
    }
  • tags: string[]

    Description

    Array of tags for the current states

  • ts: number

    Description

    Timestamp for when the state was created

tags: Set<string>

The tags of the current states of the instance.

value: TState

The current state value of the instance.

Methods

  • Does the current state value match the provided state descriptor?

    If the current state is { a: { b: "c" } }, the following all "match":

    • "a"
    • "a.b"
    • "a.b.c"
    • ["a"]
    • ["a", "b"]
    • ["a", "b", "c"]
    • { a: "b" }
    • { a: { b: "c" } }

    Parameters

    • state: AnyStateDescriptorFrom<TState>

    Returns boolean

Generated using TypeDoc