Skip to content

Function: OnProvision()

ts
function OnProvision(): LifecycleDecorator;

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

Runs when a framework provider exposes the container.

Returns

LifecycleDecorator

Method decorator.

Remarks

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

Use it for subscriptions, timers, sockets, observers, provider-scoped async work, or any resource that should be cleaned up when the provider releases the container. A class 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();
  }
}