Skip to content

Function: OnDeprovision() ​

ts
function OnDeprovision(): LifecycleDecorator<ProvisionHook>;

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

Runs before a framework provider stops exposing the container.

Returns ​

LifecycleDecorator<ProvisionHook>

Method decorator.

Remarks ​

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

Use it to clean up work started by @OnProvision. A class hierarchy may have one deprovision hook name.

Hooks run in the exact reverse of @OnProvision order, so a service can still use the dependencies it injected: they deprovision after it does.

Example ​

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

@Injectable()
class PanelService {
  @OnDeprovision()
  public onDeprovision(): void {
    this.stopPolling();
    this.disconnect();
  }
}