File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export type InspectorContext<C extends Commands = Commands> = HandlerContext<C>
56
56
flags : FallbackType < TypeFlag < NonNullable < C [ keyof C ] [ "flags" ] > > [ "flags" ] , Dict < any > >
57
57
} ;
58
58
export type Inspector < C extends Commands = Commands > = InspectorFn < C > | InspectorObject < C > ;
59
- export type InspectorFn < C extends Commands = Commands > = ( ctx : InspectorContext < C > , next : ( ) => void ) => void ;
59
+ export type InspectorFn < C extends Commands = Commands > = ( ctx : InspectorContext < C > , next : ( ) => void ) => ( ( ) => void ) | void ;
60
60
export interface InspectorObject < C extends Commands = Commands > {
61
61
enforce ?: "pre" | "post"
62
62
fn : InspectorFn < C >
Original file line number Diff line number Diff line change @@ -126,11 +126,19 @@ export function compose(inspectors: Inspector[]) {
126
126
...inspectorMap . normal ,
127
127
...inspectorMap . post ,
128
128
] ;
129
+
129
130
return ( getCtx : ( ) => InspectorContext ) => {
130
- return dispatch ( 0 ) ;
131
+ const callbacks : ( ( ) => void ) [ ] = [ ] ;
132
+ dispatch ( 0 ) ;
133
+ for ( let i = callbacks . length - 1 ; i >= 0 ; i -- ) {
134
+ callbacks [ i ] ( ) ;
135
+ }
131
136
function dispatch ( i : number ) : void {
132
137
const inspector = mergedInspectorFns [ i ] ;
133
- return inspector ( getCtx ( ) , dispatch . bind ( null , i + 1 ) ) ;
138
+ const cb = inspector ( getCtx ( ) , dispatch . bind ( null , i + 1 ) ) ;
139
+ if ( cb ) {
140
+ callbacks . push ( cb ) ;
141
+ }
134
142
}
135
143
} ;
136
144
}
You can’t perform that action at this time.
0 commit comments