interface IEvent < T > { on ( handler ) : void ; off ( handler ) : void ; } export class Event < T > implements IEvent < T > { private handlers : { ( data ? ) : void ; } [ ] = [ ] ; public on ( handler ) { this . handlers . push ( handler ) ; return ( ) => this . off ( handler ) ; } public off ( handler ) { this . handlers = this . handlers . filter ( h => h !== handler ) ; } public trigger ( data ? ) { this . handlers . slice ( 0 ) . forEach ( h => h ( data ) ) ; } public expose ( ) { return this ; } }