Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Actor<I, T, O>

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 {@link 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 {@link 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

Implements

Index

Constructors

Protected constructor

  • 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.

    throws

    When required arguments are missing.

    Parameters

    Returns Actor

Properties

Readonly beforeActors

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

Readonly bus

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

Readonly name

name: string

Methods

deinitialize

  • deinitialize(): Promise<any>
  • 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.

Protected getDefaultLogData

  • getDefaultLogData(context: ActionContext | undefined, data?: undefined | (() => any)): any

initialize

  • initialize(): Promise<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.

Protected logDebug

  • logDebug(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Protected logError

  • logError(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Protected logFatal

  • logFatal(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Protected logInfo

  • logInfo(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Protected logTrace

  • logTrace(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Protected logWarn

  • logWarn(context: ActionContext | undefined, message: string, data?: undefined | (() => any)): void

Abstract run

  • run(action: I): Promise<O>
  • Run the given action on this actor.

    In most cases, this method should not be called directly. Instead, {@link #runObservable} should be called.

    Parameters

    • action: I

      The action to run.

    Returns Promise<O>

    A promise that resolves to the run result.

runObservable

  • runObservable(action: I): Promise<O>
  • Run the given action on this actor AND invokes the {@link Bus#onRun} method.

    Parameters

    • action: I

      The action to run.

    Returns Promise<O>

    A promise that resolves to the run result.

Abstract test

  • test(action: I): Promise<T>
  • 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.

Static getContextLogger

Generated using TypeDoc