(SplashScreen) Improved the codebase of the service

This commit is contained in:
Sercan Yemen 2018-07-26 10:32:02 +03:00
parent e49771a5e0
commit 620583f99c

View File

@ -3,6 +3,8 @@ import { DOCUMENT } from '@angular/common';
import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations'; import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { filter, take } from 'rxjs/operators';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@ -46,19 +48,16 @@ export class FuseSplashScreenService
if ( this.splashScreenEl ) if ( this.splashScreenEl )
{ {
// Hide it on the first NavigationEnd event // Hide it on the first NavigationEnd event
const hideOnLoad = this._router.events.subscribe((event) => { this._router.events
if ( event instanceof NavigationEnd ) .pipe(
{ filter((event => event instanceof NavigationEnd)),
setTimeout(() => { take(1)
this.hide(); )
.subscribe(() => {
// Unsubscribe from this event so it setTimeout(() => {
// won't get triggered again this.hide();
hideOnLoad.unsubscribe(); });
}, 0); });
}
}
);
} }
} }