This class manages Behavior instances owned by a Endpoint.

Constructors

  • Parameters

    • endpoint: Endpoint<Empty>
    • options: Record<string, undefined | object>

    Returns Behaviors

Accessors

  • get [value](): Diagnostic[]
  • Returns Diagnostic[]

  • get detailedDiagnostic(): Diagnostic[][]
  • Returns Diagnostic[][]

  • get status(): Record<string, Lifecycle.Status>
  • Returns Record<string, Lifecycle.Status>

Methods

  • Activate a behavior.

    Semantically identical to createAsync() but does not return a Promise or throw an error.

    Behaviors that fail initialization will be marked with crashed status.

    Parameters

    Returns void

  • Destroy all behaviors that are initialized (have backings present). The object may be reused after close.

    Returns Promise<void>

  • Create a behavior asynchronously. Waits for the behavior to complete initialization.

    Parameters

    Returns Promise<void>

  • Create a behavior, possibly asynchronously.

    This method returns a Promise only if await is necessary so the behavior can be used immediately if possible.

    Parameters

    Returns MaybePromise<Behavior>

  • Create a behavior synchronously. Fails if the behavior is not fully initialized.

    Parameters

    Returns Behavior

  • Obtain default values for a behavior. This is state values as present when the behavior is first initialized for a new endpoint.

    Parameters

    Returns undefined | Val.Struct

  • Does the Endpoint support a specified behavior?

    Type Parameters

    Parameters

    • type: T

    Returns boolean

  • Activate any behaviors designated for immediate activation. Returns a promise iff any behaviors have ongoing initialization.

    Throws an error if any behavior crashes, but we allow all behaviors to settle before throwing. The goal is to surface multiple configuration errors and prevent inconsistent state caused by partial initialization.

    Returns MaybePromise

  • Access internal state for a Behavior.

    Internal state is not stable API and not intended for consumption outside of the behavior. However it is not truly private and may be accessed by tightly coupled implementation.

    As this API is intended for use by "friendly" code, it does not perform the same initialization assertions as does access to Behavior.State and Behavior.Events.

    Type Parameters

    Parameters

    • type: T

    Returns InstanceType<T["Internal"]>

  • Determine if a specified behavior is supported and active.

    Parameters

    Returns boolean

  • Retrieve the options for a behavior type provided to the endpoint.

    Parameters

    Returns undefined | object

  • Add behavior support dynamically at runtime. Typically called via Agent.require.

    Type Parameters

    Parameters

    Returns void

  • Ensure a set of behavior requirements are met. Throws an error detailing missing requirements.

    Parameters

    Returns void