From f7f3a60ff5963cffb04c09b41646c24abe85846e Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Sun, 26 Aug 2018 10:56:34 +0300 Subject: [PATCH] (MatchMediaService) Added a debounce so that the layout changes can work a lot more stable on media changes --- src/@fuse/services/match-media.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/@fuse/services/match-media.service.ts b/src/@fuse/services/match-media.service.ts index e096900a..9e6df82d 100644 --- a/src/@fuse/services/match-media.service.ts +++ b/src/@fuse/services/match-media.service.ts @@ -1,6 +1,7 @@ import { MediaChange, ObservableMedia } from '@angular/flex-layout'; import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; +import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; @Injectable({ providedIn: 'root' @@ -38,7 +39,11 @@ export class FuseMatchMediaService */ private _init(): void { - this._observableMedia + this._observableMedia.asObservable() + .pipe( + debounceTime(500), + distinctUntilChanged() + ) .subscribe((change: MediaChange) => { if ( this.activeMediaQuery !== change.mqAlias ) {