Feature initialization context.

Hierarchy

Properties

feature: Class<any>

Feature class this context is created for.

onComponent: OnEvent<[ComponentContext<any>]>

An OnEvent sender of component construction events.

The registered receiver will be notified right before component is constructed.

onDefinition: OnEvent<[DefinitionContext<any>]>

An OnEvent sender of component definition events.

The registered receiver will be notified when new component class is defined, but before its custom element class constructed.

supply: Supply

Feature supply.

Cut off once feature unloaded.

whenReady: OnEvent<[FeatureContext]>

An OnEvent sender of feature readiness event.

The registered receiver will be notified once bootstrap is complete and the feature is loaded.

If the above conditions satisfied already, the receiver will be notified immediately.

Methods

  • Defines a component.

    Creates a custom element according to component definition, and registers it with custom elements registry.

    Note that custom element definition will happen only when all features configuration complete.

    Returns

    Custom element class constructor registered as custom element.

    Throws

    TypeError If componentType does not contain a component definition.

    Type Parameters

    • T extends object

      A type of component.

    Parameters

    Returns void

  • Obtains value of the given context entry.

    Returns

    Either context entry value, or a fallback one.

    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

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

    Returns

    Either context entry value, or a fallback one.

    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

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

    Returns

    Either context entry value, or a fallback one.

    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

  • Allows to loads the given feature.

    Returns

    Loaded feature reference.

    Parameters

    • feature: Class<any>

      The feature to load.

    • Optional user: SupplyPeer

      The user of the feature. The feature reference will be dismissed once the user's supply is cut off.

    Returns FeatureRef

  • Provides asset for bootstrap context entry

    Note that this happens when bootstrap context already exists. To provide a value before bootstrap context created a provide method can be used.

    Returns

    Asset supply. Revokes provided asset once cut off.

    Type Parameters

    • TValue

      Context value type.

    • TAsset = TValue

      Context value asset type.

    Parameters

    Returns Supply

  • Allows to wait for component definition.

    This corresponds to window.customElements.whenDefined() method.

    Returns

    An OnEvent sender of definition context sent when the given componentType is registered.

    Type Parameters

    • T extends object

      A type of component.

    Parameters

    Returns OnEvent<[DefinitionContext<T>]>

Generated using TypeDoc