@@ -38,7 +38,7 @@ export interface On {
3838
3939export interface ListenTo {
4040 type : "listenTo" ;
41- eventName : string ;
41+ eventNames : Array < string > ;
4242 sender : EventTarget
4343}
4444export interface Always {
@@ -90,8 +90,8 @@ export function exit(f: ActionBody): ExitAction {
9090 return { type : "exit" , f } ;
9191}
9292
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 ) } ;
9595}
9696
9797export 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 {
198198 } else if ( value . type === "cond" ) {
199199 this . alwaysArray . push ( value ) ;
200200 } 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+ }
202204 } else if ( value . type === 'accumulate' ) {
203205 this . eventsToAccumulate . push ( [ value . eventName , value . resultKey ] ) ;
204206 } else if ( value . type === 'readContext' ) {
0 commit comments