Skip to content

Function: useContainer()

ts
function useContainer<E>(host: E): UseContainerValue;

Defined in: src/wirestate-lit/consumption/use-container.ts:44

Consumes the active container from the nearest Lit context.

Type Parameters

Type Parameter
E extends ReactiveControllerHost & HTMLElement

Parameters

ParameterTypeDescription
hostEHost element.

Returns

UseContainerValue

Mutable container holder.

Remarks

The returned value updates when the nearest provided container changes.

Example

typescript
class MyElement extends LitElement {
  private container: UseContainerValue = useContainer(this);

  public render() {
    return html`<div>${this.container.value.isBound(MyService)}</div>`;
  }
}