@@ -4,7 +4,8 @@ import Glob from "./glob";
4
4
import StateQueueManager from "./stateQueueManager" ;
5
5
import StateBuilder from "./stateBuilder" ;
6
6
import StateMatcher from "./stateMatcher" ;
7
- import TransitionQueue from "./transitionQueue" ;
7
+ import Queue from "../common/queue" ;
8
+ import { Transition } from "../transition/transition"
8
9
import { TransitionRejection , RejectType , RejectFactory } from "../transition/rejectFactory" ;
9
10
import { defaultTransOpts } from "../transition/transitionService" ;
10
11
import Param from "../params/param" ;
@@ -116,7 +117,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactoryProvider) {
116
117
var matcher = new StateMatcher ( states ) ;
117
118
var builder = new StateBuilder ( function ( ) { return root ; } , matcher , $urlMatcherFactoryProvider ) ;
118
119
var stateQueue = new StateQueueManager ( states , builder , $urlRouterProvider , $state ) ;
119
- var transQueue = new TransitionQueue ( ) ;
120
+ var transQueue = new Queue < Transition > ( ) ;
120
121
121
122
122
123
/**
@@ -614,11 +615,11 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactoryProvider) {
614
615
throw new Error ( `No such reload state '${ ( isString ( options . reload ) ? options . reload : options . reload . name ) } '` ) ;
615
616
}
616
617
617
- var transition = transQueue . push ( $transition . create (
618
+ var transition = transQueue . enqueue ( $transition . create (
618
619
matcher . reference ( $state . current , null , extend ( { } , $stateParams ) ) ,
619
620
matcher . reference ( to , options && options . relative , toParams ) ,
620
621
extend ( options , {
621
- current : transQueue . last . bind ( transQueue )
622
+ current : transQueue . peek . bind ( transQueue )
622
623
} )
623
624
) ) ;
624
625
@@ -661,8 +662,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactoryProvider) {
661
662
662
663
if ( error . type === RejectType . SUPERSEDED ) {
663
664
//if (error.redirected && error.detail instanceof Transition) { // TODO: expose Transition class for instanceof
664
- if ( error . redirected && error . detail && isFunction ( error . detail . run ) ) {
665
- transQueue . push ( error . detail ) ;
665
+ if ( error . redirected && error . detail instanceof Transition ) {
666
+ transQueue . enqueue ( error . detail ) ;
666
667
return stateHandler . runTransition ( error . detail ) ;
667
668
}
668
669
}
@@ -688,9 +689,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactoryProvider) {
688
689
} ;
689
690
690
691
var result = stateHandler . runTransition ( transition ) ;
691
-
692
- // Pop the transition off the queue
693
- result . finally ( pipe ( val ( transition ) , transQueue . pop . bind ( transQueue ) ) ) ;
692
+ result . finally ( ( ) => transQueue . remove ( transition ) ) ;
694
693
695
694
// Return a promise for the transition, which also has the transition object on it.
696
695
// Allows, for instance:
0 commit comments