Skip to content

Function: OnProvision()

ts
function OnProvision(): MethodDecorator;

Defined in: src/wirestate-core/service/on-provision.ts:37

Runs when a framework provider exposes the container.

Returns

MethodDecorator

Method decorator.

Remarks

React and Lit providers call this when a container enters a UI subtree. This is provider lifetime, not service lifetime.

Use it for UI-scoped subscriptions or resources that should follow a provider. A service hierarchy may have one provision hook name.

Example

typescript
import { Injectable, OnProvision } from "@wirestate/core";

@Injectable()
class PanelService {
  @OnProvision()
  public onProvision(): void {
    this.startPolling();
    this.connect();
  }
}