Interface Target<TValue, TAsset, TContext>

Context entry definition target.

Passed to context entry to start the definition.

Allows to access context values and provide assets for them.

Type Parameters

  • TValue

    Context value type.

  • TAsset = TValue

    Context value asset type.

  • TContext extends CxValues = CxValues

Hierarchy

Properties

context: TContext

Modified context.

entry: CxEntry<TValue, TAsset>

Context entry to define.

recentAsset: undefined | TAsset

The most recent asset provided for the entry.

undefined when no assets provided.

supply: Supply

Entry value supply.

The assets won't be provided any more when cut off. If applicable, disables the entry value.

This entry depends on context values supply.

Methods

  • Iterates over value assets in the same order they are provided.

    Passes each asset to the given callback function, until the latter returns false or there are no more assets.

    Parameters

    • callback: Callback<TAsset>

      Assets callback.

    Returns void

  • Iterates over value assets with the most recent assets iterated first. I.e. in reverse order to the order they are provided.

    Passes each asset to the given callback function until the latter returns false or there are no more assets.

    Parameters

    • callback: Callback<TAsset>

      Assets callback.

    Returns void

  • Obtains value of the given context entry.

    Type Parameters

    • TValue

      Requested context value type.

    Parameters

    • entry: CxEntry<TValue, unknown>

      Context entry to obtain the value of.

    • Optional request: WithoutFallback<TValue>

      Context value request with fallback specified.

    Returns TValue

    Either context entry value, or a fallback one.

  • Obtains value of the given context entry, or returns a non-nullable fallback.

    Type Parameters

    • TValue

      Requested context value type.

    Parameters

    • entry: CxEntry<TValue, unknown>

      Context entry to obtain the value of.

    • request: WithFallback<TValue>

      Context value request with fallback specified.

    Returns TValue

    Either context entry value, or a fallback one.

  • Obtains value of the given context entry, or returns a nullable fallback.

    Throws

    CxReferenceError - If the target entry has no value and fallback one is not provided.

    Type Parameters

    • TValue

      Requested context value type.

    Parameters

    • entry: CxEntry<TValue, unknown>

      Context entry to obtain the value of.

    • Optional request: CxRequest<TValue>

      Context value request.

    Returns null | TValue

    Either context entry value, or a fallback one.

  • Creates a lazy evaluator against this entry definition target instance.

    Type Parameters

    • T

      Evaluation result type.

    Parameters

    • evaluator: ((this, target) => T)

      Evaluator function accepting this entry definition target instance as its only parameter and returning some result.

        • (this, target): T
        • Parameters

          • this: void
          • target: Target<TValue, TAsset, TContext>

          Returns T

    Returns ((this) => T)

    A function without parameters returning the evaluated result. The result will be evaluated at most once.

      • (this): T
      • Creates a lazy evaluator against this entry definition target instance.

        Parameters

        • this: void

        Returns T

        A function without parameters returning the evaluated result. The result will be evaluated at most once.

  • Provides an asset for context entry.

    Type Parameters

    • TValue

      Context value type.

    • TAsset = TValue

      Context value asset type.

    Parameters

    • asset: CxAsset<TValue, TAsset, TContext>

      Context entry asset.

    Returns Supply

    Asset supply. Revokes provided asset once cut off.

  • Reads entry assets list and start tracking of their additions.

    Sends a list of already provided assets to the given receiver, then sends it again on whenever asset provided or revoked, until the returned asset supply cut off.

    Parameters

    Returns Supply

    Assets list supply. Stops tracking once cut off.

  • Reads entry assets and start tracking of their additions.

    Sends already provided assets to the given receiver, then sends every added assets too, until the returned asset supply cut off.

    Parameters

    Returns Supply

    Assets supply. Stops tracking once cut off.

  • Reads the most recent entry asset and starts its tracking.

    The most recent asset is the one with the smallest rank provided last.

    Sends the recent asset to the given receiver, then sends again whenever the recent asset changes. Sends undefined when there are no assets provided for the entry.

    Parameters

    Returns Supply

    Most recent assets supply. Stops tracking once cut off.

Generated using TypeDoc