mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
(SplashScreen) Improved the codebase of the service
This commit is contained in:
parent
e49771a5e0
commit
620583f99c
|
@ -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);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user