Skip to content

Function: OnDeactivation()

ts
function OnDeactivation(): MethodDecorator;

Defined in: src/wirestate-core/service/on-deactivation.ts:35

Runs a service method during container deactivation.

Returns

MethodDecorator

Method decorator.

Remarks

Deactivation happens when the container unbinds or disposes the service.

Use it to cancel timers, close sockets, and flush work. A service hierarchy may have one deactivation hook name.

Example

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

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