Skip to content

Commit

Permalink
fix(module:core): remove resize listener when the app is destroyed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Jan 13, 2022
1 parent 1ceaf70 commit 8437111
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions components/core/services/breakpoint.ts
Expand Up @@ -4,9 +4,9 @@
*/

import { MediaMatcher } from '@angular/cdk/layout';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { distinctUntilChanged, map, startWith } from 'rxjs/operators';
import { Injectable, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { distinctUntilChanged, map, startWith, takeUntil } from 'rxjs/operators';

import { NzResizeService } from './resize';

Expand Down Expand Up @@ -44,9 +44,18 @@ export const siderResponsiveMap: BreakpointMap = {
@Injectable({
providedIn: 'root'
})
export class NzBreakpointService {
export class NzBreakpointService implements OnDestroy {
private destroy$ = new Subject<void>();

constructor(private resizeService: NzResizeService, private mediaMatcher: MediaMatcher) {
this.resizeService.subscribe().subscribe(() => {});
this.resizeService
.subscribe()
.pipe(takeUntil(this.destroy$))
.subscribe(() => {});
}

ngOnDestroy(): void {
this.destroy$.next();
}

subscribe(breakpointMap: BreakpointMap): Observable<NzBreakpointEnum>;
Expand Down

0 comments on commit 8437111

Please sign in to comment.