Function: useSubContainerProvider()
ts
function useSubContainerProvider<E>(host: E, options: SubContainerProviderOptions): SubContainerProvider<E>;Defined in: src/wirestate-lit/provision/use-sub-container-provider.ts:36
Hook that provides a managed child container for the host element's lifetime.
Type Parameters
| Type Parameter |
|---|
E extends ReactiveControllerHost & HTMLElement |
Parameters
| Parameter | Type | Description |
|---|---|---|
host | E | The host element. |
options | SubContainerProviderOptions | Provisioning options. |
Returns
An instance of SubContainerProvider.
Remarks
The child container is derived from the current parent ContainerContext, recreated when that parent context changes, and destroyed when the host disconnects. Provider lifecycle hooks run while the child container is connected.
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 {
private containerProvider: SubContainerProvider = useSubContainerProvider(this, {
config: {
entries: [AuthService, UserService],
},
});
}