@@ -4,7 +4,7 @@ import {extend, tail, assertPredicate, unnestR, identity} from "../common/common
4
4
import { isArray } from "../common/predicates" ;
5
5
6
6
import {
7
- TransitionOptions , TransitionHookOptions , IHookRegistry , TreeChanges , IEventHook , IMatchingNodes ,
7
+ TransitionOptions , TransitionHookOptions , IHookRegistry , TreeChanges , IMatchingNodes ,
8
8
TransitionHookPhase , TransitionHookScope
9
9
} from "./interface" ;
10
10
@@ -14,15 +14,16 @@ import {State} from "../state/stateObject";
14
14
import { PathNode } from "../path/node" ;
15
15
import { TransitionService } from "./transitionService" ;
16
16
import { TransitionHookType } from "./transitionHookType" ;
17
+ import { RegisteredHook } from "./hookRegistry" ;
17
18
18
19
/**
19
20
* This class returns applicable TransitionHooks for a specific Transition instance.
20
21
*
21
- * Hooks (IEventHook ) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
22
- * myTransition.onEnter(...). The HookBuilder finds matching IEventHooks (where the match criteria is
22
+ * Hooks ([[RegisteredHook]] ) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
23
+ * myTransition.onEnter(...). The HookBuilder finds matching RegisteredHooks (where the match criteria is
23
24
* determined by the type of hook)
24
25
*
25
- * The HookBuilder also converts IEventHooks objects to TransitionHook objects, which are used to run a Transition.
26
+ * The HookBuilder also converts RegisteredHooks objects to TransitionHook objects, which are used to run a Transition.
26
27
*
27
28
* The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder
28
29
* instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private
@@ -62,7 +63,7 @@ export class HookBuilder {
62
63
/**
63
64
* Returns an array of newly built TransitionHook objects.
64
65
*
65
- * - Finds all IEventHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
66
+ * - Finds all RegisteredHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
66
67
* - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)
67
68
* - For each of the [[PathNode]]s, creates a TransitionHook
68
69
*
@@ -73,7 +74,7 @@ export class HookBuilder {
73
74
let matchingHooks = this . getMatchingHooks ( hookType , this . treeChanges ) ;
74
75
if ( ! matchingHooks ) return [ ] ;
75
76
76
- const makeTransitionHooks = ( hook : IEventHook ) => {
77
+ const makeTransitionHooks = ( hook : RegisteredHook ) => {
77
78
// Fetch the Nodes that caused this hook to match.
78
79
let matches : IMatchingNodes = hook . matches ( this . treeChanges ) ;
79
80
// Select the PathNode[] that will be used as TransitionHook context objects
@@ -87,7 +88,7 @@ export class HookBuilder {
87
88
} , this . baseHookOptions ) ;
88
89
89
90
let state = hookType . hookScope === TransitionHookScope . STATE ? node . state : null ;
90
- let transitionHook = new TransitionHook ( this . transition , state , hook , hookType , _options ) ;
91
+ let transitionHook = new TransitionHook ( this . transition , state , hook , _options ) ;
91
92
return < HookTuple > { hook, node, transitionHook } ;
92
93
} ) ;
93
94
} ;
@@ -99,30 +100,30 @@ export class HookBuilder {
99
100
}
100
101
101
102
/**
102
- * Finds all IEventHooks from:
103
+ * Finds all RegisteredHooks from:
103
104
* - The Transition object instance hook registry
104
105
* - The TransitionService ($transitions) global hook registry
105
106
*
106
107
* which matched:
107
108
* - the eventType
108
109
* - the matchCriteria (to, from, exiting, retained, entering)
109
110
*
110
- * @returns an array of matched [[IEventHook ]]s
111
+ * @returns an array of matched [[RegisteredHook ]]s
111
112
*/
112
- public getMatchingHooks ( hookType : TransitionHookType , treeChanges : TreeChanges ) : IEventHook [ ] {
113
+ public getMatchingHooks ( hookType : TransitionHookType , treeChanges : TreeChanges ) : RegisteredHook [ ] {
113
114
let isCreate = hookType . hookPhase === TransitionHookPhase . CREATE ;
114
115
115
116
// Instance and Global hook registries
116
117
let registries = isCreate ? [ this . $transitions ] : [ this . transition , this . $transitions ] ;
117
118
118
119
return registries . map ( ( reg : IHookRegistry ) => reg . getHooks ( hookType . name ) ) // Get named hooks from registries
119
120
. filter ( assertPredicate ( isArray , `broken event named: ${ hookType . name } ` ) ) // Sanity check
120
- . reduce ( unnestR , [ ] ) // Un-nest IEventHook [][] to IEventHook [] array
121
+ . reduce ( unnestR , [ ] ) // Un-nest RegisteredHook [][] to RegisteredHook [] array
121
122
. filter ( hook => hook . matches ( treeChanges ) ) ; // Only those satisfying matchCriteria
122
123
}
123
124
}
124
125
125
- interface HookTuple { hook : IEventHook , node : PathNode , transitionHook : TransitionHook }
126
+ interface HookTuple { hook : RegisteredHook , node : PathNode , transitionHook : TransitionHook }
126
127
127
128
/**
128
129
* A factory for a sort function for HookTuples.
0 commit comments