A kind of the value a component shares with the nested ones.

The sharing implies the following:

  • The sharer component registers its element name as the one bound to sharer.
  • The sharer component provides an (updatable) shared value within its context.
  • The consumer component obtains the shared value by searching the parent element with a sharer bound to it.

A share instance is used as an identifier in all these steps.

A @Shared component property decorator may be used to automate this.

Type Parameters

  • T

    Shared value type.

Hierarchy

  • Share

Implements

Constructors

Properties

[Share$impl__symbol]: Share$<T>

Accessors

Methods

  • Registers a sharer component.

    The registration is necessary for consumers to be able to find the element bound to sharer by that element's name.

    Returns

    Sharer registration supply. Revokes the sharer registration once cut off.

    Parameters

    • defContext: DefinitionContext<any>

      The definition context of the sharer component.

    • Optional options: SharedValue.Options

      Value sharing options.

    Returns Supply

  • Selects a shared value among candidates.

    It is especially useful when the value shared by multiple sharers.

    By default:

    Returns

    Either selected value, or undefined when not present.

    Parameters

    Returns undefined | T

  • Shares a value by providing it for the sharer component context.

    Returns

    A builder of shared value for component context.

    Parameters

    • registrar: Registrar<T>

      Shared value registrar.

    Returns void

  • Locates a shared value for the consuming component.

    Searches among parent elements for the one bound to the sharer component, then obtains the shared value from the sharer's context.

    Returns

    An AfterEvent keeper of the shared value and its sharer context, if found.

    Parameters

    • consumer: ComponentContext<any>

      Consumer component context.

    • options: ShareLocator.Options = {}

      Location options.

    Returns AfterEvent<[] | [T, ComponentContext<any>]>

Generated using TypeDoc