Composed Interface
The result of composing multiple components.
For more information about our API support guarantees, see here.
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
| Parameter | Default | Description |
|---|---|---|
| TComponent | The content each component contributes. | |
| TConfig | ComposedDefault<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
| Property | Alerts | Modifiers | Type | Description |
|---|---|---|---|---|
| components | Alpha | readonly | readonly TComponent[] | The components which were composed. |
| config | Alpha | readonly | TConfig | The configuration which was produced when composing. |
Methods
| Method | Alerts | Return Type | Description |
|---|---|---|---|
| getComponent(factory) | Alpha | ReturnType<TFactory> | Get a component by its factory. |
| getComposed(property) | Alpha | readonly (Exclude<TComponent[TKey], undefined> extends LazyArray<infer U> ? () => U : never)[] | Compose the contents of a LazyArray property from all components. |
| getConfigured(configurable) | Alpha | ReturnType<TConfigurable["configure"]> | Configure a Configurable. |
Property Details
components
The components which were composed.
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.
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.
For more information about our API support guarantees, see here.
Signature
getComponent<TFactory extends Factory<TComponent, TConfig>>(factory: TFactory): ReturnType<TFactory>;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| TFactory | Factory<TComponent, TConfig> |
Parameters
| Parameter | Type | Description |
|---|---|---|
| factory | TFactory | The 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.
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
| Parameter | Constraint | Description |
|---|---|---|
| TKey | keyof { [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
| Parameter | Type | Description |
|---|---|---|
| property | TKey | The 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.
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
| Parameter | Constraint | Description |
|---|---|---|
| TConfigurable | Configurable<TConfig, unknown, TComponent> |
Remarks
The result is cached when first evaluated, so subsequent calls with the same configurable return the same result.
Parameters
| Parameter | Type | Description |
|---|---|---|
| configurable | TConfigurable | The item to configure against this composition. |
Returns
Return type: ReturnType<TConfigurable["configure"]>