Skip to content

ActorLogic <TSnapshot, TEvent, TInput, TSystem>

Represents logic which can be used by an actor.

Implemented by

Index

Properties

optionalconfig

config?: unknown

The initial setup/configuration used to create the actor logic.

getInitialSnapshot

getInitialSnapshot: (actorScope: ActorScope<TSnapshot, TEvent, TSystem>, input: TInput) => TSnapshot

Type declaration

    • (actorScope: ActorScope<TSnapshot, TEvent, TSystem>, input: TInput): TSnapshot
    • Called to provide the initial state of the actor.


      Parameters

      • actorScope: ActorScope<TSnapshot, TEvent, TSystem>

        The actor scope.

      • input: TInput

        The input for the initial state.

      Returns TSnapshot

      The initial state.

getPersistedSnapshot

getPersistedSnapshot: (snapshot: TSnapshot, options?: unknown) => Snapshot<unknown>

Type declaration

    • (snapshot: TSnapshot, options?: unknown): Snapshot<unknown>
    • Obtains the internal state of the actor in a representation which can be be persisted. The persisted state can be restored by restoreSnapshot.


      Parameters

      • snapshot: TSnapshot

        The current state.

      • optionaloptions: unknown

      Returns Snapshot<unknown>

      The a representation of the internal state to be persisted.

optionalrestoreSnapshot

restoreSnapshot?: (persistedState: Snapshot<unknown>, actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>) => TSnapshot

Type declaration

    • (persistedState: Snapshot<unknown>, actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>): TSnapshot
    • Called when Actor is created to restore the internal state of the actor given a persisted state. The persisted state can be created by getPersistedSnapshot.


      Parameters

      • persistedState: Snapshot<unknown>

        The persisted state to restore from.

      • actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>

        The actor scope.

      Returns TSnapshot

      The restored state.

optionalstart

start?: (snapshot: TSnapshot, actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>) => void

Type declaration

    • (snapshot: TSnapshot, actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>): void
    • Called when the actor is started.


      Parameters

      • snapshot: TSnapshot

        The starting state.

      • actorScope: ActorScope<TSnapshot, TEvent, AnyActorSystem>

        The actor scope.

      Returns void

transition

transition: (snapshot: TSnapshot, message: TEvent, actorScope: ActorScope<TSnapshot, TEvent, TSystem>) => TSnapshot

Type declaration

    • (snapshot: TSnapshot, message: TEvent, actorScope: ActorScope<TSnapshot, TEvent, TSystem>): TSnapshot
    • Transition function that processes the current state and an incoming message to produce a new state.


      Parameters

      • snapshot: TSnapshot

        The current state.

      • message: TEvent

        The incoming message.

      • actorScope: ActorScope<TSnapshot, TEvent, TSystem>

        The actor scope.

      Returns TSnapshot

      The new state.