Class: SubContainerProvider<E>
Defined in: src/wirestate-lit/provision/sub-container-provider.ts:87
Reactive controller that provides a managed child container.
Remarks
The child container inherits parent bindings but owns its own buses, seeds, and lifecycle. It is recreated when the parent container changes.
Child containers activate all entries by default unless activate is set. Before connect and after disconnect, the context value is undefined.
Example
class MyComponent extends LitElement {
private container = new SubContainerProvider(this, {
config: {
entries: [AuthService, UserService],
seeds: [[AuthService, { role: "admin" }]],
},
});
}Extends
ContextProvider<typeofContainerContext,E>
Type Parameters
| Type Parameter | Default type |
|---|---|
E extends ReactiveControllerHost & HTMLElement | ReactiveControllerHost & HTMLElement |
Implements
ReactiveController
Accessors
value
Get Signature
get value(): T;Defined in: @lit/context:
Returns
T
Set Signature
set value(v: T): void;Defined in: @lit/context:
Parameters
| Parameter | Type |
|---|---|
v | T |
Returns
void
Inherited from
ContextProvider.valueConstructors
Constructor
new SubContainerProvider<E>(host: E, options: SubContainerProviderOptions): SubContainerProvider<E>;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:103
Parameters
| Parameter | Type | Description |
|---|---|---|
host | E | The host element. |
options | SubContainerProviderOptions | Provisioning options, including child entries, eager activations, and seeds. |
Returns
SubContainerProvider<E>
Overrides
ContextProvider<typeof ContainerContext, E>.constructorMethods
addCallback()
addCallback(
callback: ContextCallback<Container>,
consumerHost: Element,
subscribe?: boolean): void;Defined in: @lit/context:
Parameters
| Parameter | Type |
|---|---|
callback | ContextCallback<Container> |
consumerHost | Element |
subscribe? | boolean |
Returns
void
Inherited from
ContextProvider.addCallbackclearCallbacks()
clearCallbacks(): void;Defined in: @lit/context:
Returns
void
Inherited from
ContextProvider.clearCallbackscreateContainer()
protected createContainer(): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:199
Replaces the currently provided child container with a new one derived from the latest parent context.
Returns
void
destroyContainer()
protected destroyContainer(): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:220
Destroys the currently provided child container.
Returns
void
hostConnected()
hostConnected(): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:142
Returns
void
Implementation of
ReactiveController.hostConnectedOverrides
ContextProvider.hostConnectedhostDisconnected()
hostDisconnected(): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:152
Called when the host is disconnected from the component tree. For custom element hosts, this corresponds to the disconnectedCallback() lifecycle, which is called the host or an ancestor component is disconnected from the document.
Returns
void
Implementation of
ReactiveController.hostDisconnectedsetConfig()
setConfig(config: {
activate?: ContainerActivation;
entries: readonly (
| Newable<object>
| InjectableDescriptor<unknown, unknown>)[];
seeds?: SeedEntries;
}): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:184
Replaces the managed child-container config.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | { activate?: ContainerActivation; entries: readonly ( | Newable<object> | InjectableDescriptor<unknown, unknown>)[]; seeds?: SeedEntries; } | Child-container creation options to use from now on. |
config.activate? | ContainerActivation | Services to activate (get from container) immediately after binding. Remarks Defaults to true, activating all provided entries. Pass false to skip eager activation, or pass an array to activate specific entries. |
config.entries | readonly ( | Newable<object> | InjectableDescriptor<unknown, unknown>)[] | List of service entries to bind to the container. |
config.seeds? | SeedEntries | Seed data to apply to the container before binding. Applied before entries are bound so that @Inject(SEEDS_TOKEN) works during activation. |
Returns
void
Remarks
When the provider is not currently provisioning a child container, the config is stored for the next connect. When it is active, the current child container is deprovisioned, destroyed, and recreated from the new config.
setValue()
setValue(container: Container, force?: boolean): void;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:164
Parameters
| Parameter | Type |
|---|---|
container | Container |
force? | boolean |
Returns
void
Overrides
ContextProvider.setValueProperties
config
protected config: {
activate?: ContainerActivation;
entries: readonly (
| Newable<object>
| InjectableDescriptor<unknown, unknown>)[];
seeds?: SeedEntries;
};Defined in: src/wirestate-lit/provision/sub-container-provider.ts:94
| Name | Type | Description | Defined in |
|---|---|---|---|
activate? | ContainerActivation | Services to activate (get from container) immediately after binding. Remarks Defaults to true, activating all provided entries. Pass false to skip eager activation, or pass an array to activate specific entries. | src/wirestate-lit/provision/sub-container-provider.ts:53 |
entries | readonly ( | Newable<object> | InjectableDescriptor<unknown, unknown>)[] | List of service entries to bind to the container. | src/wirestate-lit/provision/sub-container-provider.ts:44 |
seeds? | SeedEntries | Seed data to apply to the container before binding. Applied before entries are bound so that @Inject(SEEDS_TOKEN) works during activation. | src/wirestate-lit/provision/sub-container-provider.ts:59 |
consumer
protected readonly consumer: ContextConsumer<{
__context__: Container;
}, E>;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:93
destroyed
protected destroyed: boolean = true;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:97
host
protected readonly host: E;Defined in: @lit/context:
Inherited from
ContextProvider.hostlifecycle
protected readonly lifecycle: ProvisionLifecycle;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:91
onContextRequest
onContextRequest: (ev: ContextRequestEvent<{
__context__: unknown;
}>) => void;Defined in: @lit/context:
Parameters
| Parameter | Type |
|---|---|
ev | ContextRequestEvent<{ __context__: unknown; }> |
Returns
void
Inherited from
ContextProvider.onContextRequestonProviderRequest
onProviderRequest: (ev: ContextProviderEvent<{
__context__: unknown;
}>) => void;Defined in: @lit/context:
When we get a provider request event, that means a child of this element has just woken up. If it's a provider of our context, then we may need to re-parent our subscriptions, because is a more specific provider than us for its subtree.
Parameters
| Parameter | Type |
|---|---|
ev | ContextProviderEvent<{ __context__: unknown; }> |
Returns
void
Inherited from
ContextProvider.onProviderRequestparent
protected parent: Maybe<Container> = null;Defined in: src/wirestate-lit/provision/sub-container-provider.ts:96
subscriptions
protected readonly subscriptions: Map<ContextCallback<Container>, CallbackInfo>;Defined in: @lit/context:
Inherited from
ContextProvider.subscriptionsupdateObservers
updateObservers: () => void;Defined in: @lit/context:
Returns
void
Inherited from
ContextProvider.updateObservers