Skip to content

Function: useScope()

ts
function useScope<E>(host: E): UseScopeValue;

Defined in: src/wirestate-lit/consumption/use-scope.ts:42

Consumes a WireScope from the nearest Lit container context.

Type Parameters

Type Parameter
E extends ReactiveControllerHost & HTMLElement

Parameters

ParameterTypeDescription
hostEHost element.

Returns

UseScopeValue

Mutable scope holder.

Remarks

The returned value updates when the nearest provided container changes.

Example

typescript
class MyElement extends LitElement {
  private scope: UseScopeValue = useScope(this);

  public connectedCallback(): void {
    super.connectedCallback();
    this.scope.value.emitEvent("UI_READY");
  }
}