Function: subContainerProvide()
ts
function subContainerProvide<E>(options: SubContainerProviderOptions): SubContainerProviderDecorator<E>;Defined in: src/wirestate-lit/provision/sub-container-provide.ts:60
Decorator that provides a managed child container derived from the nearest parent container context.
Type Parameters
| Type Parameter | Default type |
|---|---|
E extends ReactiveElement | ReactiveElement |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SubContainerProviderOptions | Provisioning options. |
Returns
SubContainerProviderDecorator<E>
An instance of SubContainerProviderDecorator.
Remarks
The child container is created from the current parent context when the host connects, provider lifecycle hooks run while connected, destroyed when it disconnects, and recreated when the parent container changes.
The child container value is published through Lit context only while the host is connected. Before the first connection and after disconnection, the provider value is undefined.
Example
typescript
class MyComponent extends LitElement {
@subContainerProvide({
config: {
entries: [AuthService, UserService],
activate: [AuthService],
},
})
public containerProvider!: SubContainerProvider<MyComponent>;
}