Skip to content

Commit 626c69d

Browse files
committed
refactor(toasters): use takeUntilDestroyed() operator
1 parent dd1291f commit 626c69d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: src/app/views/notifications/toasters/toasters.component.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit, QueryList, ViewChildren } from '@angular/core';
2+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
23
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
34
import { Observable } from 'rxjs';
45
import { filter } from 'rxjs/operators';
@@ -33,8 +34,6 @@ export class ToastersComponent implements OnInit {
3334
delay = 5000;
3435
fade = true;
3536

36-
formChanges!: Observable<any>;
37-
3837
toasterForm = new UntypedFormGroup({
3938
autohide: new UntypedFormControl(this.autohide),
4039
delay: new UntypedFormControl({value: this.delay, disabled: !this.autohide}),
@@ -44,10 +43,14 @@ export class ToastersComponent implements OnInit {
4443
color: new UntypedFormControl('')
4544
});
4645

46+
formChanges: Observable<any> = this.toasterForm.valueChanges.pipe(
47+
takeUntilDestroyed(),
48+
filter(e => e.autohide !== this.autohide)
49+
);
50+
4751
@ViewChildren(ToasterComponent) viewChildren!: QueryList<ToasterComponent>;
4852

4953
ngOnInit(): void {
50-
this.formChanges = this.toasterForm.valueChanges.pipe(filter(e => e.autohide !== this.autohide));
5154
this.formChanges.subscribe(e => {
5255
this.autohide = e.autohide;
5356
this.position = e.position;

0 commit comments

Comments
 (0)