Skip to content

Function: OnDeactivation()

ts
function OnDeactivation(): LifecycleDecorator;

Defined in: src/wirestate-core/activation/on-deactivation.ts:43

Runs an instance method during container deactivation.

Returns

LifecycleDecorator

Method decorator.

Remarks

Deactivation happens when the container unbinds or disposes the instance.

Use it for container-disposal cleanup. Prefer @OnDeprovision for work started by provider ownership, such as subscriptions, timers, sockets, and observers. A class hierarchy may have one deactivation hook name.

Example

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

@Injectable()
class FeedService {
  @OnDeactivation()
  public onDeactivation(): void {
    this.disposeResources();
  }
}