@@ -38,7 +38,7 @@ export interface On {
38
38
39
39
export interface ListenTo {
40
40
type : "listenTo" ;
41
- eventName : string ;
41
+ eventNames : Array < string > ;
42
42
sender : EventTarget
43
43
}
44
44
export interface Always {
@@ -90,8 +90,8 @@ export function exit(f: ActionBody): ExitAction {
90
90
return { type : "exit" , f } ;
91
91
}
92
92
93
- export function listenTo ( sender : EventTarget , eventName : string ) : ListenTo {
94
- return { type : "listenTo" , sender, eventName } ;
93
+ export function listenTo ( sender : EventTarget , eventNames : string | Array < string > ) : ListenTo {
94
+ return { type : "listenTo" , sender, eventNames : ( [ ] as Array < string > ) . concat ( eventNames ) } ;
95
95
}
96
96
97
97
export function send < Method extends string | symbol , Arguments extends any [ ] > ( target : ( ) => Record < Method , ( ...args : Arguments ) => void > , method : Method , args : Arguments ) : Send < Method , Arguments > {
@@ -198,7 +198,9 @@ class Handlers {
198
198
} else if ( value . type === "cond" ) {
199
199
this . alwaysArray . push ( value ) ;
200
200
} else if ( value . type === 'listenTo' ) {
201
- this . eventsToListenTo . push ( [ value . eventName , value . sender ] ) ;
201
+ for ( const eventName of value . eventNames ) {
202
+ this . eventsToListenTo . push ( [ eventName , value . sender ] ) ;
203
+ }
202
204
} else if ( value . type === 'accumulate' ) {
203
205
this . eventsToAccumulate . push ( [ value . eventName , value . resultKey ] ) ;
204
206
} else if ( value . type === 'readContext' ) {
0 commit comments