import { Component, Injector, OnDestroy } from '@angular/core';
import { ActivatedRouteSnapshot, NavigationEnd, NavigationStart, Router } from '@angular/router';
-import { from, Observable, of, Subscription } from 'rxjs';
-import { concat, distinct, filter, first, flatMap, toArray } from 'rxjs/operators';
+import { concat, from, Observable, of, Subscription } from 'rxjs';
+import { distinct, filter, first, mergeMap, toArray } from 'rxjs/operators';
-import { BreadcrumbsResolver, IBreadcrumb } from '../../../shared/models/breadcrumbs';
+import { BreadcrumbsResolver, IBreadcrumb } from '~/app/shared/models/breadcrumbs';
@Component({
selector: 'cd-breadcrumbs',
export class BreadcrumbsComponent implements OnDestroy {
crumbs: IBreadcrumb[] = [];
/**
- * Usefull for e2e tests.
+ * Useful for e2e tests.
* This allow us to mark the breadcrumb as pending during the navigation from
* one page to another.
* This resolves the problem of validating the breadcrumb of a new page and
this._resolveCrumbs(currentRoot)
.pipe(
- flatMap((x) => x),
+ mergeMap((x) => x),
distinct((x) => x.text),
toArray(),
- flatMap((x) => {
+ mergeMap((x) => {
const y = this.postProcess(x);
return this.wrapIntoObservable<IBreadcrumb[]>(y).pipe(first());
})
let resolver: BreadcrumbsResolver;
if (data.breadcrumbs.prototype instanceof BreadcrumbsResolver) {
- resolver = this.injector.get(data.breadcrumbs);
+ resolver = this.injector.get<BreadcrumbsResolver>(data.breadcrumbs);
} else {
resolver = this.defaultResolver;
}
}
if (route.firstChild) {
- crumbs$ = crumbs$.pipe(concat(this._resolveCrumbs(route.firstChild)));
+ crumbs$ = concat<IBreadcrumb[]>(crumbs$, this._resolveCrumbs(route.firstChild));
}
return crumbs$;