Browse Source

Eliminate OnDestroy lifecycle hook

pull/6654/head
Thomas Kaul 6 days ago
parent
commit
950635aa96
  1. 16
      apps/client/src/app/components/subscription-interstitial-dialog/subscription-interstitial-dialog.component.ts

16
apps/client/src/app/components/subscription-interstitial-dialog/subscription-interstitial-dialog.component.ts

@ -7,9 +7,11 @@ import {
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
DestroyRef,
Inject, Inject,
OnInit OnInit
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { import {
MAT_DIALOG_DATA, MAT_DIALOG_DATA,
@ -21,8 +23,8 @@ import { IonIcon } from '@ionic/angular/standalone';
import { addIcons } from 'ionicons'; import { addIcons } from 'ionicons';
import { arrowForwardOutline, checkmarkCircleOutline } from 'ionicons/icons'; import { arrowForwardOutline, checkmarkCircleOutline } from 'ionicons/icons';
import ms from 'ms'; import ms from 'ms';
import { interval, Subject } from 'rxjs'; import { interval } from 'rxjs';
import { take, takeUntil, tap } from 'rxjs/operators'; import { take, tap } from 'rxjs/operators';
import { SubscriptionInterstitialDialogParams } from './interfaces/interfaces'; import { SubscriptionInterstitialDialogParams } from './interfaces/interfaces';
@ -51,11 +53,10 @@ export class GfSubscriptionInterstitialDialogComponent implements OnInit {
public routerLinkPricing = publicRoutes.pricing.routerLink; public routerLinkPricing = publicRoutes.pricing.routerLink;
public variantIndex: number; public variantIndex: number;
private unsubscribeSubject = new Subject<void>();
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DIALOG_DATA) public data: SubscriptionInterstitialDialogParams, @Inject(MAT_DIALOG_DATA) public data: SubscriptionInterstitialDialogParams,
private destroyRef: DestroyRef,
public dialogRef: MatDialogRef<GfSubscriptionInterstitialDialogComponent> public dialogRef: MatDialogRef<GfSubscriptionInterstitialDialogComponent>
) { ) {
this.variantIndex = Math.floor( this.variantIndex = Math.floor(
@ -76,7 +77,7 @@ export class GfSubscriptionInterstitialDialogComponent implements OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}), }),
takeUntil(this.unsubscribeSubject) takeUntilDestroyed(this.destroyRef)
) )
.subscribe(); .subscribe();
} }
@ -84,9 +85,4 @@ export class GfSubscriptionInterstitialDialogComponent implements OnInit {
public closeDialog() { public closeDialog() {
this.dialogRef.close({}); this.dialogRef.close({});
} }
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
} }

Loading…
Cancel
Save