Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(router): create pipeable afterPreactivation function (#25740)
PR Close #25740
- Loading branch information
Showing
2 changed files
with
37 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {MonoTypeOperatorFunction} from 'rxjs'; | ||
import {map, mergeMap} from 'rxjs/operators'; | ||
|
||
import {RouterHook} from '../router'; | ||
import {RouterStateSnapshot} from '../router_state'; | ||
import {UrlTree} from '../url_tree'; | ||
|
||
export function afterPreactivation( | ||
hook: RouterHook, navigationId: number, appliedUrlTree: UrlTree, rawUrlTree: UrlTree, | ||
skipLocationChange: boolean, replaceUrl: boolean): | ||
MonoTypeOperatorFunction<{appliedUrl: UrlTree, snapshot: RouterStateSnapshot}> { | ||
return function(source) { | ||
return source.pipe(mergeMap( | ||
p => hook( | ||
p.snapshot, | ||
{ | ||
navigationId, appliedUrlTree, rawUrlTree, skipLocationChange, replaceUrl, | ||
}) | ||
.pipe(map(() => p)))); | ||
}; | ||
} |
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