@@ -61,10 +61,15 @@ export type ActionCancelType =
61
61
| 'widget' ;
62
62
63
63
64
+ /**
65
+ * The definition for the actual action pipe handler function.
66
+ */
67
+ export type ActionPipeHandler = ( ...args : any [ ] ) => RunnableHooks | void ;
68
+
64
69
/**
65
70
* Basic definition of a game engine action file (.action.ts exports).
66
71
*/
67
- export type ActionPipe = [ ActionType , ( ... args : any [ ] ) => void ] ;
72
+ export type ActionPipe = [ ActionType , ActionPipeHandler ] ;
68
73
69
74
70
75
/**
@@ -86,7 +91,7 @@ export interface RunnableHooks<T = any> {
86
91
*/
87
92
export class ActionPipeline {
88
93
89
- private static pipes = new Map < string , any > ( ) ;
94
+ private static pipes = new Map < string , ActionPipeHandler > ( ) ;
90
95
91
96
private runningTasks : TaskExecutor < any > [ ] = [ ] ;
92
97
private canceling : boolean = false ;
@@ -97,12 +102,12 @@ export class ActionPipeline {
97
102
. subscribe ( async ( ) => this . cancelRunningTasks ( ) ) ;
98
103
}
99
104
100
- public static getPipe ( action : ActionType ) : Map < string , any > {
105
+ public static getPipe ( action : ActionType ) : ActionPipeHandler {
101
106
return ActionPipeline . pipes . get ( action ) ;
102
107
}
103
108
104
- public static register ( action : ActionType , actionPipe : ( ... args : any [ ] ) => void ) : void {
105
- ActionPipeline . pipes . set ( action . toString ( ) , actionPipe ) ;
109
+ public static register ( action : ActionType , actionPipeHandlerFn : ActionPipeHandler ) : void {
110
+ ActionPipeline . pipes . set ( action . toString ( ) , actionPipeHandlerFn ) ;
106
111
}
107
112
108
113
public shutdown ( ) : void {
@@ -113,7 +118,7 @@ export class ActionPipeline {
113
118
const actionHandler = ActionPipeline . pipes . get ( action . toString ( ) ) ;
114
119
if ( actionHandler ) {
115
120
try {
116
- await this . runActionHandler ( actionHandler , ... args ) ;
121
+ await this . runActionHandler ( actionHandler , args ) ;
117
122
} catch ( error ) {
118
123
if ( error ) {
119
124
logger . error ( `Error handling action ${ action . toString ( ) } ` ) ;
@@ -141,7 +146,7 @@ export class ActionPipeline {
141
146
this . canceling = false ;
142
147
}
143
148
144
- private async runActionHandler ( actionHandler : any , ... args : any [ ] ) : Promise < void > {
149
+ private async runActionHandler ( actionHandler : any , args : any [ ] ) : Promise < void > {
145
150
const runnableHooks : RunnableHooks | null | undefined = await actionHandler ( ...args ) ;
146
151
147
152
if ( ! runnableHooks ?. hooks || runnableHooks . hooks . length === 0 ) {
@@ -150,7 +155,6 @@ export class ActionPipeline {
150
155
151
156
for ( let i = 0 ; i < runnableHooks . hooks . length ; i ++ ) {
152
157
const hook = runnableHooks . hooks [ i ] ;
153
-
154
158
if ( ! hook ) {
155
159
continue ;
156
160
}
0 commit comments