/**
 * Event handler map for event registry
 */ export class EventHandlerMap { private map : Map < string , any [ ] > ; constructor ( ) { this . map = new Map < string , any [ ] > ( ) ; } add ( key , func ) { const arr = this . map . get ( key ) ; if ( arr ) { arr . push ( func ) ; } else { this . map . set ( key , Array . of ( func ) ) ; } } remove ( key , func ) { const arr = this . map . get ( key ) ; if ( arr ) { const id = arr . indexOf ( func ) ; if ( id > - 1 ) { arr . splice ( id , 1 ) ; } } } async exec ( key , param ) { const arr = this . map . get ( key ) ; if ( arr ) { arr . forEach ( async ( fn ) => { await fn ( param ) ; } ) ; } } }