(MatchMediaService) Added a debounce so that the layout changes can work a lot more stable on media changes

This commit is contained in:
Sercan Yemen 2018-08-26 10:56:34 +03:00
parent 08e2d5f331
commit f7f3a60ff5

View File

@ -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 )
{