import { Directive, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';

@Directive()
export class UnsubscribeDirective implements OnDestroy {
  private subscriptions: Subscription[] = [];

  ngOnDestroy(): void {
    this.subscriptions.forEach(sub => sub.unsubscribe());
  }

  unsubscribeOnDestroy(...sub: Subscription[]): void {
    this.subscriptions.push(...sub);
  }
}
