type Listener = ( ... args : Array < any > ) => void ; export class SimpleEmitter { listeners : Listener [ ] = [ ] ; emit ( name ? ) { this . listeners . forEach ( ( listener ) => { listener ( ) ; } ) ; } addListener ( event , fn ) { this . listeners . push ( fn ) ; } on ( event , fn ) { this . addListener ( event , fn ) ; } removeListener ( event , fn ) { const listeners = [ ] ; for ( let i = 0 ; i < this . listeners . length ; i ++ ) { if ( this . listeners [ i ] !== fn ) { listeners . push ( this . listeners [ i ] ) ; } } this . listeners = listeners ; } off ( event , fn ) { this . removeListener ( event , fn ) ; } }