Мне удалось решить это с помощью ответов выше.Тем не менее, они не полностью ответили на мой вопрос, и, возможно, есть лучший способ.Мое решение:
const end$ = this.router.events.pipe(
map(() => false),
);
const start$ = this.router.events.pipe(
map(() => true),
);
merge(
end$,
start$.pipe(
switchMap(() => {
return race(end$, of(true).pipe(delay(2000)));
}),
filter((value) => value === true) // this really works only with booleans, not sure how I'd do it with more
// complex objects
)
).subscribe((value) => {
console.log(value);
});