Function: useContainer()
ts
function useContainer<E>(host: E): UseContainerValue;Defined in: src/wirestate-lit/consumption/use-container.ts:47
Consumes the active container from the nearest Lit context.
Type Parameters
| Type Parameter |
|---|
E extends ReactiveControllerHost & HTMLElement |
Parameters
| Parameter | Type | Description |
|---|---|---|
host | E | Host element. |
Returns
Container holder that resolves to the active container.
Remarks
The returned value updates when the nearest provided container changes. Reading value before the context resolves (no container provider above the host) throws.
Example
typescript
import { LitElement, html } from "lit";
class MyElement extends LitElement {
private container: UseContainerValue = useContainer(this);
public render() {
return html`<div>${this.container.value.has(MyService)}</div>`;
}
}