@@ -372,7 +372,7 @@ export class NavigationTransitions {
372
372
get hasRequestedNavigation ( ) {
373
373
return this . navigationId !== 0 ;
374
374
}
375
- private transitions ?: BehaviorSubject < NavigationTransition > ;
375
+ private transitions ?: BehaviorSubject < NavigationTransition | null > ;
376
376
/**
377
377
* Hook that enables you to pause navigation after the preactivation phase.
378
378
* Used by `RouterModule`.
@@ -416,45 +416,21 @@ export class NavigationTransitions {
416
416
> ,
417
417
) {
418
418
const id = ++ this . navigationId ;
419
- this . transitions ?. next ( { ...this . transitions . value , ...request , id} ) ;
420
- }
421
-
422
- setupNavigations (
423
- router : InternalRouterInterface ,
424
- initialUrlTree : UrlTree ,
425
- initialRouterState : RouterState ,
426
- ) : Observable < NavigationTransition > {
427
- this . transitions = new BehaviorSubject < NavigationTransition > ( {
428
- id : 0 ,
429
- currentUrlTree : initialUrlTree ,
430
- currentRawUrl : initialUrlTree ,
431
- extractedUrl : this . urlHandlingStrategy . extract ( initialUrlTree ) ,
432
- urlAfterRedirects : this . urlHandlingStrategy . extract ( initialUrlTree ) ,
433
- rawUrl : initialUrlTree ,
434
- extras : { } ,
435
- resolve : ( ) => { } ,
436
- reject : ( ) => { } ,
437
- promise : Promise . resolve ( true ) ,
438
- source : IMPERATIVE_NAVIGATION ,
439
- restoredState : null ,
440
- currentSnapshot : initialRouterState . snapshot ,
419
+ this . transitions ?. next ( {
420
+ ...request ,
421
+ extractedUrl : this . urlHandlingStrategy . extract ( request . rawUrl ) ,
441
422
targetSnapshot : null ,
442
- currentRouterState : initialRouterState ,
443
423
targetRouterState : null ,
444
424
guards : { canActivateChecks : [ ] , canDeactivateChecks : [ ] } ,
445
425
guardsResult : null ,
426
+ id,
446
427
} ) ;
447
- return this . transitions . pipe (
448
- filter ( ( t ) => t . id !== 0 ) ,
428
+ }
449
429
450
- // Extract URL
451
- map (
452
- ( t ) =>
453
- ( {
454
- ...t ,
455
- extractedUrl : this . urlHandlingStrategy . extract ( t . rawUrl ) ,
456
- } ) as NavigationTransition ,
457
- ) ,
430
+ setupNavigations ( router : InternalRouterInterface ) : Observable < NavigationTransition > {
431
+ this . transitions = new BehaviorSubject < NavigationTransition | null > ( null ) ;
432
+ return this . transitions . pipe (
433
+ filter ( ( t ) : t is NavigationTransition => t !== null ) ,
458
434
459
435
// Using switchMap so we cancel executing navigations when a new one comes in
460
436
switchMap ( ( overallTransitionState ) => {
@@ -522,7 +498,6 @@ export class NavigationTransitions {
522
498
return of ( t ) . pipe (
523
499
// Fire NavigationStart event
524
500
switchMap ( ( t ) => {
525
- const transition = this . transitions ?. getValue ( ) ;
526
501
this . events . next (
527
502
new NavigationStart (
528
503
t . id ,
@@ -531,7 +506,7 @@ export class NavigationTransitions {
531
506
t . restoredState ,
532
507
) ,
533
508
) ;
534
- if ( transition !== this . transitions ?. getValue ( ) ) {
509
+ if ( t . id !== this . navigationId ) {
535
510
return EMPTY ;
536
511
}
537
512
0 commit comments