Class PropertyTracker<T>

Instances of this class are used in place of regular member variables on other objects as a way to get dirty checking & undo functionality built into them, eg:

private _velocityTracker = new PropertyTracker<number>(100);
get velocity(): number { return this._velocityTracker.value; }
set velocity(value: number) { this._velocityTracker.value = value; }

Type Parameters

  • T

Hierarchy

  • PropertyTracker

Constructors

Properties

Accessors

Methods

Constructors

  • Type Parameters

    Type Parameters

    • T

    Parameters

    • Optional initValue: T

      The initial accepted value that the tracker gets instanciated with

    Returns PropertyTracker<T>

Properties

oldValue: T

The last accepted value

value: T

The most up-to-date value

Accessors

  • get isDirty(): boolean
  • Has the property changed since it was last accepted?

    Returns boolean

Methods

  • Accept changes made to the property, no longer hang on to the old property value

    Returns void

  • Undo changes made to the property, revert back to the last accepted property value

    Returns void

Generated using TypeDoc