Class CxBuilder<TContext>

Context builder.

Provides value assets for the context.

Type Parameters

  • TContext extends CxValues = CxValues

    A type of context to build.

Hierarchy

Implements

  • CxValues

Constructors

  • Constructs context builder.

    Type Parameters

    • TContext extends CxValues = CxValues

    Parameters

    • createContext: ((this, getValue, builder) => TContext)

      Context creator function. Accepts context value accessor and the builder itself as parameters, and returns created context.

        • (this, getValue, builder): TContext
        • Parameters

          • this: void
          • getValue: CxAccessor
          • builder: CxBuilder<TContext>

          Returns TContext

    • Rest ...peers: CxPeer<TContext>[]

      Context peers to apply assets from. These assets applied before the ones provided * explicitly. Peers listed later have lesser CxAsset.Provided.rank rank values than the ones listed earlier.

    Returns CxBuilder<TContext>

Properties

_bound: (() => CxPeer<CxValues>) = ...

Type declaration

_cache: CxBuilder$Cache = ...
_cx: (() => TContext)

Type declaration

    • (): TContext
    • Internal

      Returns TContext

_peers: readonly CxPeer<TContext>[]

Accessors

  • get boundPeer(): CxPeer<CxValues>
  • A peer providing assets bound to context.

    Unlike the builder itself, this peer may provide assets for any context, as they constructed in compatible one.

    Returns CxPeer<CxValues>

  • get context(): TContext
  • Context to build.

    Returns TContext

  • get rankCount(): number
  • The number of CxAsset.Provided.rank asset ranks this peer contains.

    Returns number

  • get supply(): Supply
  • Context peer supply.

    Revokes all assets provided by this peer once cut off.

    Returns Supply

Methods

  • Internal

    Type Parameters

    • TValue

    • TAsset

    Parameters

    • entry: CxEntry<TValue, TAsset>

    Returns CxEntry$Record<TValue, TAsset, TContext>

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

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

    Type Parameters

    • TValue

    • TAsset

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target to iterate over assets of.

    • cache: Cache

      Target context cache.

    • callback: Callback<TAsset>

      Assets callback.

    Returns void

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

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

    Type Parameters

    • TValue

    • TAsset

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target to iterate over assets of.

    • cache: Cache

      Target context cache.

    • callback: Callback<TAsset>

      Assets callback.

    Returns void

  • Type Parameters

    • TValue

    Parameters

    • entry: CxEntry<TValue, any>
    • Optional request: WithoutFallback<TValue>

    Returns TValue

  • Type Parameters

    • TValue

    Parameters

    • entry: CxEntry<TValue, any>
    • request: WithFallback<TValue>

    Returns TValue

  • Type Parameters

    • TValue

    Parameters

    • entry: CxEntry<TValue, any>
    • Optional request: CxRequest<TValue>

    Returns null | TValue

  • Type Parameters

    • TValue

    • TAsset = TValue

    Parameters

    • asset: CxAsset<TValue, TAsset, TContext>

    Returns Supply

  • Reads assets of particular entry value and start tracking of their additions.

    Type Parameters

    • TValue

    • TAsset

    Parameters

    • target: Target<TValue, TAsset, TContext>

      Context entry definition target to track assets for.

    • cache: Cache

      Target context cache.

    • receiver: Receiver<TAsset>

      A receiver to report existing and added assets to.

    • Optional tracking: CxTracking

      Tracking options.

    Returns Supply

    Assets supply. Stops assets tracking once cut off.

Generated using TypeDoc