export default class CachedProperty < T > { private bound_properties : CachedProperty < any > [ ] = [ ] ; constructor ( private value , private updateFn ) { } public update ( ... args ) { this . value = this . updateFn . apply ( null , args ) ; for ( let i = 0 ; i < this . bound_properties . length ; i ++ ) { this . bound_properties [ i ] . update ( ... args ) ; } } public get ( ) { return this . value ; } public updateAndGet ( ) { this . update ( ) ; return this . get ( ) ; } public addBoundProperty ( cached_property ) { this . bound_properties . push ( cached_property ) ; } }