export type Handler < E > = ( event : E ) => void ; export class EventDispatcher < E > { private handlers : Handler < E > [ ] = [ ] ; fire ( event ) { for ( let h of this . handlers ) h ( event ) ; } register ( handler ) { this . handlers . push ( handler ) ; } }