Class InspectableProperty

The InspectableProperty provides access to the value and meta-data of a TypeScript field. The primary use-case for this class is type reflection within the Inspector APIs. The InspectableProperty wraps other inspectable types such as InspectableArray and InspectableMap.

Constructors

  • Creates a new serializable property.

    Parameters

    • getter: (() => any)

      Method that allows you to retrieve contents of the property.

        • (): any
        • Returns any

    • setter: ((value: any) => void)

      Method that allows you to set contents of the property

        • (value): void
        • Parameters

          • value: any

          Returns void

    • style: InspectablePropertyDecoration

      A class that determines how the property should be displayed on the UI.

    • OptionalreassignOnChildChanges: boolean

      Only relevant if the property represents an object. When true, whenever a child property changes value, this property's setter will be called with the new modified version of the object. This is useful for value-types, for reference types being passed by copy, or for situations where changes to an object must be explicitly applied by re-assigning the object.

    Returns InspectableProperty

Properties

Determines the decoration of the inspectable property.

internalElementTypes: Type[]

If the InternalType is an array type, this will contain the type of the elements in that array. It will contain null if InternalType is not an array type or if the element type was not specified or deduced.

internalType: Type

Returns type of data the property contains, as TypeScript type.

isDirty: boolean

Determines if the field value was changed recently.

reassignOnChildChanges: boolean

Only relevant if the property represents an object. When true, whenever a child property changes value, this property's setter will be called with the new modified version of the object. This is useful for value-types, for reference types being passed by copy, or for situations where changes to an object must be explicitly applied by re-assigning the object.

Returns type of data the property contains.

Accessors

  • get internalElementType(): Type
  • If the InternalType is an array type, this will contain the type of the elements in that array. It will contain null if InternalType is not an array type or if the element type was not specified or deduced.

    Returns Type

  • get isReadOnlySelf(): boolean
  • Determines if the property itself is readonly, independent of parent states.

    Returns boolean

Methods

  • Creates a new instance of the array wrapped by this property. Caller must ensure this property contains an array.

    Parameters

    • lengths: number[]

      Size of each dimension of the array. Number of dimensions must match the number of dimensions in the array wrapped by this property.

    Returns any[]

    A new array containing the same element type as the array wrapped by this property, of lengths sizes.

  • Creates a new instance of the map wrapped by this property. Caller must ensure this property contains a map.

    Returns Map<any, any>

    A new map containing the same key/value types as the map wrapped by this property.

  • Creates a new instance of the type wrapped by this property.

    Type Parameters

    • T

      Type of the object to create. Caller must ensure the type matches the property type and that the property wraps an object.

    Returns T

    A new instance of an object of type .

  • Helper method used for finding child properties of the specified property, using a property path. InspectableObject.findProperty.

    Parameters

    • pathElements: PropertyPathElement[]

      Path elements representing field names and keys to look for.

    • elementIdx: number

      Index in the pathElements array to start the search at.

    Returns InspectableProperty

    Property representing the final path element, or null if not found (array index is out of range, or property with that path doesn't exist).

  • Retrieves the value contained in the property.

    Type Parameters

    • T

      Type of the value to retrieve. Caller must ensure the type matches the property type.

    Returns ValueTypeOf<T>

    Value of the property.

  • Retrieves the value contained in the property.

    Type Parameters

    • T

      Type of the value to retrieve. Caller must ensure the type matches the property type.

    Parameters

    Returns ValueTypeOf<T>

    Value of the property.

  • Gets the type of the stored value.

    Returns Type

  • Changes the value of the property.

    Type Parameters

    • T

      Type of the value to set. Caller must ensure the type matches the property type.

    Parameters

    Returns void

  • Changes the value of the property.

    Type Parameters

    • T

      Type of the value to set. Caller must ensure the type matches the property type.

    Parameters

    Returns void

  • Returns a serializable array around the value contained in the property. Caller must ensure the property contains an array.

    Returns InspectableArray

    Serializable array around the value contained in the property.

  • Returns a serializable map around the value contained in the property. Caller must ensure the property contains a map.

    Returns InspectableMap

    Serializable map around the value contained in the property.

  • Returns a serializable object wrapper around the value contained in the property.

    Returns InspectableObject<any>

    Serializable object wrapper around the value contained in the property.

  • Returns a serializable property for the field.

    Type Parameters

    • T extends object

    Parameters

    Returns InspectableProperty

    Serializable property that allows you to manipulate contents of the field.