/**
 * Holds a reference to a value. Multiple things can share the reference, or
 * have their own. The shared value can be changed to a new value making all
 * other references dirty so they know they need to be updated.
 */ export class Ref < T > { /**
     * If this reference is holding a dirty (out of date) value.
     */ public dirty : boolean ; /**
     * If the value is shared by multiple things.
     */ public shared : boolean ; /**
     * The value the reference points to.
     */ public value : T ; param value param shared public constructor ( value , shared ) { this . value = value ; this . shared = shared ; this . dirty = false ; } param newValue public getUpdate ( newValue ) { if ( this . shared ) { return new Ref < T > ( newValue , false ) ; } else { this . value = newValue ; return this ; } } param newValue public getReplace ( newValue ) { if ( this . shared ) { this . dirty = true ; return new Ref < T > ( newValue , true ) ; } else { this . value = newValue ; return this ; } } }