Component definition context.

Extends ContextValues interface. The values are provided by corresponding providers registered with perDefinition and perDefinition methods. All BootstrapContext values are available too.

Type Parameters

  • T extends object = any

    A type of component.

Hierarchy

  • CxValues
    • DefinitionContext

Properties

componentType: ComponentClass<T>

Component class constructor.

elementDef: ElementDef

Custom element definition.

elementType: Class<any>

Custom element class constructor.

It is an error accessing this property before the element class is created, e.g. from inside of define function. In such case you may wish to add a whenReady() callback.

whenComponent: OnEvent<[ComponentContext<T>]>

An OnEvent sender of component context upon its instantiation.

If component instantiated after the receiver is registered, that receiver would receive an instantiated component's context immediately.

If component already exists when the receiver is registered, that receiver would receive instantiated component's context only when/if component is connected. This is to prevent resource leaks on destroyed components.

whenReady: OnEvent<[DefinitionContext<T>]>

An OnEvent sender of component definition context upon its readiness.

The custom element class is not constructed until component definition is complete. The registered receiver will be notified when the custom element class is constructed.

If the custom element class is constructed already, the receiver will be notified immediately.

Methods

  • 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

  • Mounts a component to arbitrary element.

    This method creates a component, but instead of creating a custom element for, it mounts it to the target element.

    It is up to the features to update the target element. They can use a mounted flag to check whether the component is mounted or constructed in a standard way.

    The constructed component connection state is maintained by DocumentRenderKit document render kit.

    Returns

    Mounted component context.

    Throws

    Error If target element is already bound to some component.

    Parameters

    Returns ComponentContext<T>

  • Provides asset for entry available in contexts of each component of the defined component type.

    Returns

    Asset supply. Revokes provided asset once cut off.

    Type Parameters

    • TValue

      Context value type.

    • TAsset = TValue

      Context value asset type.

    Parameters

    Returns Supply

Generated using TypeDoc