Created
December 2, 2018 11:30
-
-
Save nathan-lapinski/e11be380a1b9a2f89d419dd3b42b2941 to your computer and use it in GitHub Desktop.
excerpt of router.ts demonstrating how switchMap is used to cancel and cleanup pending navigations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private setupNavigations(transitions: Observable<NavigationTransition>): Observable<NavigationTransition> { | |
return transitions.pipe( | |
filter(t => t.id !== 0), | |
// Extract URL | |
map(t => ({...t, extractedUrl: this.urlHandlingStrategy.extract(t.rawUrl)}) as NavigationTransition), | |
// Using switchMap so we cancel executing navigations when a new one comes in | |
switchMap(t => { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment