module export default class Observer < Observable > { private observers : Array < ObserverHandler < Observable > > = [ ] ; public register ( observer ) { this . observers . push ( observer ) ; } public unregister ( observer ) { const n = this . observers . indexOf ( observer ) ; this . observers . splice ( n , 1 ) ; } public notify ( obj ) { let i = 0 ; const max = this . observers . length ; for ( ; i < max ; i += 1 ) { this . observers [ i ] . notify ( obj ) ; } } } export class ObserverHandler < Observable > { public notify ( obj ) { throw new Error ( 'Abstract Method!' ) ; } }