Skip to main content

Composed Interface

The result of composing multiple components.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
interface Composed<TComponent, TConfig = ComposedDefault<TComponent>>

Type Parameters

ParameterDefaultDescription
TComponentThe content each component contributes.
TConfigComposedDefault<TComponent>The composed configuration type made available to components. Defaults to the composition itself: the common case where no custom configuration type is needed.

Remarks

Create using compose(allComponents).

Properties

PropertyAlertsModifiersTypeDescription
componentsAlphareadonlyreadonly TComponent[]The components which were composed.
configAlphareadonlyTConfigThe configuration which was produced when composing.

Methods

MethodAlertsReturn TypeDescription
getComponent(factory)AlphaReturnType<TFactory>Get a component by its factory.
getComposed(property)Alphareadonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U> ? () => U : never)[]Compose the contents of a LazyArray property from all components.
getConfigured(configurable)AlphaReturnType<TConfigurable["configure"]>Configure a Configurable.

Property Details

components

The components which were composed.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

readonly components: readonly TComponent[];

Type: readonly TComponent[]

config

The configuration which was produced when composing.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

readonly config: TConfig;

Type: TConfig

Method Details

getComponent

Get a component by its factory.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

getComponent<TFactory extends Factory<TComponent, TConfig>>(factory: TFactory): ReturnType<TFactory>;
Type Parameters
ParameterConstraintDescription
TFactoryFactory<TComponent, TConfig>

Parameters

ParameterTypeDescription
factoryTFactoryThe factory used to look up the component. Must have been provided when composing.

Returns

The content created by the provided factory. This result is cached during composition and not reevaluated.

Return type: ReturnType<TFactory>

getComposed

Compose the contents of a LazyArray property from all components.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

getComposed<TKey extends keyof {
[Property in keyof TComponent as TComponent[Property] extends LazyArray<unknown> | undefined ? Property : never]: boolean;
}>(property: TKey): readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U> ? () => U : never)[];
Type Parameters
ParameterConstraintDescription
TKeykeyof { [Property in keyof TComponent as TComponent[Property] extends LazyArray<unknown> | undefined ? Property : never]: boolean; }

Remarks

The result is cached when first evaluated, so subsequent calls with the same property return the same result.

Parameters

ParameterTypeDescription
propertyTKeyThe property of the components to compose.

Returns

The concatenation of the lazy values contributed by each component for property. Components which omit the property contribute nothing.

Return type: readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U> ? () => U : never)[]

getConfigured

Configure a Configurable.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

getConfigured<TConfigurable extends Configurable<TConfig, unknown, TComponent>>(configurable: TConfigurable): ReturnType<TConfigurable["configure"]>;
Type Parameters
ParameterConstraintDescription
TConfigurableConfigurable<TConfig, unknown, TComponent>

Remarks

The result is cached when first evaluated, so subsequent calls with the same configurable return the same result.

Parameters

ParameterTypeDescription
configurableTConfigurableThe item to configure against this composition.

Returns

Return type: ReturnType<TConfigurable["configure"]>