File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55
66import { MediaMatcher } from '@angular/cdk/layout' ;
7- import { Injectable } from '@angular/core' ;
8- import { Observable } from 'rxjs' ;
9- import { distinctUntilChanged , map , startWith } from 'rxjs/operators' ;
7+ import { Injectable , OnDestroy } from '@angular/core' ;
8+ import { Observable , Subject } from 'rxjs' ;
9+ import { distinctUntilChanged , map , startWith , takeUntil } from 'rxjs/operators' ;
1010
1111import { NzResizeService } from './resize' ;
1212
@@ -44,9 +44,18 @@ export const siderResponsiveMap: BreakpointMap = {
4444@Injectable ( {
4545 providedIn : 'root'
4646} )
47- export class NzBreakpointService {
47+ export class NzBreakpointService implements OnDestroy {
48+ private destroy$ = new Subject < void > ( ) ;
49+
4850 constructor ( private resizeService : NzResizeService , private mediaMatcher : MediaMatcher ) {
49- this . resizeService . subscribe ( ) . subscribe ( ( ) => { } ) ;
51+ this . resizeService
52+ . subscribe ( )
53+ . pipe ( takeUntil ( this . destroy$ ) )
54+ . subscribe ( ( ) => { } ) ;
55+ }
56+
57+ ngOnDestroy ( ) : void {
58+ this . destroy$ . next ( ) ;
5059 }
5160
5261 subscribe ( breakpointMap : BreakpointMap ) : Observable < NzBreakpointEnum > ;
You can’t perform that action at this time.
0 commit comments