type Callback = ( ) => void ; export class Eventing { events : { [ key ] : Callback [ ] ; } = { } ; on = ( eventName , callback ) : void => { const handlers = this . events [ eventName ] || [ ] ; handlers . push ( callback ) ; this . events [ eventName ] = handlers ; } ; trigger = ( eventName ) : void => { const handlers = this . events [ eventName ] ; if ( ! handlers || handlers . length === 0 ) { return ; } handlers . forEach ( callback => { callback ( ) ; } ) ; } ; }