Interface Base<TValue, TAsset, TContext>

Base interface of context entry asset implementations.

Type Parameters

  • TValue

    Context value type.

  • TAsset

    Context value asset type.

  • TContext extends CxValues

    Context type.

Hierarchy

Properties

entry: CxEntry<TValue, TAsset>

Target context entry.

supply?: Supply

Asset supply.

Removes the asset once cut off.

Returned from provide when specified. New one created when omitted.

Methods

  • Builds value asset provider. The provider would then place value assets to the target context entry.

    In contrast to placeAsset, this method is called at most once per context. If provider will be called each time value assets requested.

    This method also supports updatable assets. For that, an update function is passed as second parameter. Call it to inform the interested parties on value asset update. The updated asset has to be provided by provider returned earlier.

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target.

    • update: ((this) => void)

      A function to call when asset updated.

        • (this): void
        • Parameters

          • this: void

          Returns void

    Returns undefined | null | false | ((this, collector) => void)

    Value assets provider accepting assets collector to place assets to as its only parameter, or falsy value if there are no value assets.

  • Evaluates value asset or multiple assets and places them to target context entry.

    Passes each evaluated asset to the given collector, until the latter returns false or there are no more assets to place.

    This method is called each time value assets requested.

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target.

    • collector: Collector<TAsset>

      Assets collector to place assets to.

    Returns void

  • Sets up asset.

    This method is called immediately when asset provided.

    It can be used e.g. to provide additional assets. Additional assets will be revoked when the asset itself revoked.

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target.

    Returns void

Generated using TypeDoc