@@ -30,7 +30,7 @@ export function matchState(state: State, criterion: HookMatchCriterion) {
30
30
function matchGlobs ( _state : State ) {
31
31
let globStrings = < string [ ] > toMatch ;
32
32
for ( let i = 0 ; i < globStrings . length ; i ++ ) {
33
- let glob = Glob . fromString ( globStrings [ i ] ) ;
33
+ let glob = new Glob ( globStrings [ i ] ) ;
34
34
35
35
if ( ( glob && glob . matches ( _state . name ) ) || ( ! glob && globStrings [ i ] === _state . name ) ) {
36
36
return true ;
@@ -75,9 +75,9 @@ export class EventHook implements IEventHook {
75
75
let mc = this . matchCriteria , _matchingNodes = EventHook . _matchingNodes ;
76
76
77
77
let matches : IMatchingNodes = {
78
- to : _matchingNodes ( [ tail ( treeChanges . to ) ] , mc . to ) ,
79
- from : _matchingNodes ( [ tail ( treeChanges . from ) ] , mc . from ) ,
80
- exiting : _matchingNodes ( treeChanges . exiting , mc . exiting ) ,
78
+ to : _matchingNodes ( [ tail ( treeChanges . to ) ] , mc . to ) ,
79
+ from : _matchingNodes ( [ tail ( treeChanges . from ) ] , mc . from ) ,
80
+ exiting : _matchingNodes ( treeChanges . exiting , mc . exiting ) ,
81
81
retained : _matchingNodes ( treeChanges . retained , mc . retained ) ,
82
82
entering : _matchingNodes ( treeChanges . entering , mc . entering ) ,
83
83
} ;
@@ -92,10 +92,13 @@ export class EventHook implements IEventHook {
92
92
}
93
93
94
94
/** @hidden */
95
- interface ITransitionEvents { [ key : string ] : IEventHook [ ] ; }
95
+ export interface IEventHooks {
96
+ [ key : string ] : IEventHook [ ] ;
97
+ }
96
98
97
99
/** @hidden Return a registration function of the requested type. */
98
- function makeHookRegistrationFn ( hooks : ITransitionEvents , name : string ) : IHookRegistration {
100
+ export function makeHookRegistrationFn ( hooks : IEventHooks , name :string ) : IHookRegistration {
101
+ hooks [ name ] = [ ] ;
99
102
return function ( matchObject , callback , options = { } ) {
100
103
let eventHook = new EventHook ( matchObject , callback , options ) ;
101
104
hooks [ name ] . push ( eventHook ) ;
@@ -105,48 +108,4 @@ function makeHookRegistrationFn(hooks: ITransitionEvents, name: string): IHookRe
105
108
removeFrom ( hooks [ name ] ) ( eventHook ) ;
106
109
} ;
107
110
} ;
108
- }
109
-
110
- /**
111
- * Mixin class acts as a Transition Hook registry.
112
- *
113
- * Holds the registered [[HookFn]] objects.
114
- * Exposes functions to register new hooks.
115
- *
116
- * This is a Mixin class which can be applied to other objects.
117
- *
118
- * The hook registration functions are [[onBefore]], [[onStart]], [[onEnter]], [[onRetain]], [[onExit]], [[onFinish]], [[onSuccess]], [[onError]].
119
- *
120
- * This class is mixed into both the [[TransitionService]] and every [[Transition]] object.
121
- * Global hooks are added to the [[TransitionService]].
122
- * Since each [[Transition]] is itself a `HookRegistry`, hooks can also be added to individual Transitions
123
- * (note: the hook criteria still must match the Transition).
124
- */
125
- export class HookRegistry implements IHookRegistry {
126
- static mixin ( source : HookRegistry , target : IHookRegistry ) {
127
- Object . keys ( source . _transitionEvents ) . concat ( [ "getHooks" ] ) . forEach ( key => target [ key ] = source [ key ] ) ;
128
- }
129
-
130
- private _transitionEvents : ITransitionEvents = {
131
- onBefore : [ ] , onStart : [ ] , onEnter : [ ] , onRetain : [ ] , onExit : [ ] , onFinish : [ ] , onSuccess : [ ] , onError : [ ]
132
- } ;
133
-
134
- getHooks = ( name : string ) => this . _transitionEvents [ name ] ;
135
-
136
- /** @inheritdoc */
137
- onBefore = makeHookRegistrationFn ( this . _transitionEvents , "onBefore" ) ;
138
- /** @inheritdoc */
139
- onStart = makeHookRegistrationFn ( this . _transitionEvents , "onStart" ) ;
140
- /** @inheritdoc */
141
- onEnter = makeHookRegistrationFn ( this . _transitionEvents , "onEnter" ) ;
142
- /** @inheritdoc */
143
- onRetain = makeHookRegistrationFn ( this . _transitionEvents , "onRetain" ) ;
144
- /** @inheritdoc */
145
- onExit = makeHookRegistrationFn ( this . _transitionEvents , "onExit" ) ;
146
- /** @inheritdoc */
147
- onFinish = makeHookRegistrationFn ( this . _transitionEvents , "onFinish" ) ;
148
- /** @inheritdoc */
149
- onSuccess = makeHookRegistrationFn ( this . _transitionEvents , "onSuccess" ) ;
150
- /** @inheritdoc */
151
- onError = makeHookRegistrationFn ( this . _transitionEvents , "onError" ) ;
152
- }
111
+ }
0 commit comments