export default class ValueEventEmitter { _value : any ; private eventListeners : Array < ( value : any ) => any > = [ ] ; constructor ( value ? ) { this . _value = value ; } get value ( ) { return this . _value ; } set value ( newValue ) { this . _value = newValue ; this . eventListeners . forEach ( eventListener => { eventListener . call ( null , this . value ) ; } ) ; } addEventListener = ( eventListener ) => { this . eventListeners . push ( eventListener ) ; return ( ) => { this . removeEventListener ( eventListener ) ; } ; } ; removeEventListener = ( eventListener ) => { const index = this . eventListeners . findIndex ( listener => listener === eventListener ) ; if ( index !== - 1 ) { this . eventListeners . splice ( index , 1 ) ; } } ; }