Class Actor<I, T, O>Abstract

An actor can act on messages of certain types and provide output of a certain type.

The flow of an actor is as follows:

  1. Send a message to Actor#test to test if an actor can run that action.
  2. If the actor can reply to the message, let the actor run the action using Actor#run.

An actor is typically subscribed to a bus, using which the applicability to an action can be tested.

See

Bus

Type Parameters

Hierarchy

  • Actor

    Implements

    Constructors

    • All enumerable properties from the args object are inherited to this actor.

      The actor will subscribe to the given bus when this constructor is called.

      Type Parameters

      Parameters

      Returns Actor<I, T, O>

      Throws

      When required arguments are missing.

    Properties

    beforeActors: Actor<I, T, O>[] = []

    Actor that must be registered in the bus before this actor.

    bus: Bus<Actor<I, T, O>, I, T, O>

    The bus this actor subscribes to.

    name: string

    The name for this actor.

    Default

    {<rdf:subject>}
    

    Methods

    • Deinitialize this actor. This should be used for cleaning up things when the application is shut down, such as closing files and removing temporary files.

      Returns Promise<any>

      A promise that resolves when the actor has been deinitialized.

    • Parameters

      Returns any

    • Initialize this actor. This should be used for doing things that take a while, such as opening files.

      Returns Promise<any>

      A promise that resolves when the actor has been initialized.

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Parameters

      • context: IActionContext
      • message: string
      • Optional data: (() => any)
          • (): any
          • Returns any

      Returns void

    • Run the given action on this actor.

      In most cases, this method should not be called directly. Instead, #runObservable should be called.

      Parameters

      • action: I

        The action to run.

      Returns Promise<O>

      A promise that resolves to the run result.

    • Run the given action on this actor AND invokes the Bus#onRun method.

      Parameters

      • action: I

        The action to run.

      Returns Promise<O>

      A promise that resolves to the run result.

    • Check if this actor can run the given action, without actually running it.

      Parameters

      • action: I

        The action to test.

      Returns Promise<T>

      A promise that resolves to the test result.

    • Get the logger from the given context.

      Parameters

      Returns undefined | Logger

      The logger or undefined.

    Generated using TypeDoc