Browse Source

Refactor router-events.service.ts

pull/19505/head
Masum ULU 2 years ago
committed by GitHub
parent
commit
0a2e8a18f1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      npm/ng-packs/packages/core/src/lib/services/router-events.service.ts

15
npm/ng-packs/packages/core/src/lib/services/router-events.service.ts

@ -34,15 +34,12 @@ export class RouterEvents {
}
protected listenToNavigation(): void {
(
this.router.events.pipe(
filter(e => e instanceof NavigationEvent.End && !e.url.includes('error')),
) as Observable<NavigationEnd>
).subscribe(event => {
// It must be "NavigationTransition" but it is not exported in Angular
//https://github.com/angular/angular/blob/9c486c96827a9282cbdbff176761bc95554a260b/packages/router/src/navigation_transition.ts#L282
this.#previousNavigation.set(this.#currentNavigation());
const routerEvent$ = this.router.events.pipe(
filter(e => e instanceof NavigationEvent.End && !e.url.includes('error'))
) as Observable<NavigationEnd>;
routerEvent$.subscribe(event => {
this.#previousNavigation.set(this.currentNavigation());
this.#currentNavigation.set(event.url);
});
}

Loading…
Cancel
Save