An object that can be serialized to/from plain JSON.

interface Serializable<TProperties> {
    assignProperties(properties: Partial<TProperties>): void;
    assignPropertiesAsync(properties: Partial<TProperties>): Promise<void>;
    finishAssignProperties(): Promise<void>;
    getDefault<K>(key: K): TProperties[K];
    getDefaults(): Partial<TProperties>;
    getSerializableProperties(serializeMode?: SerializeMode): PropertyDefs<TProperties>;
    toJSON(serializeMode?: SerializeMode): Partial<TProperties>;
}

Type Parameters

  • TProperties

Hierarchy (view full)

Implemented by

Methods

  • Sets the properties for this item.

    Parameters

    • properties: Partial<TProperties>

      A plain object containing property values to set, keyed by property name.

    Returns void

  • Sets the properties for this item.

    This version will also await any asynchronous logic that is needed to set the properties.

    Parameters

    • properties: Partial<TProperties>

      A plain object containing property values to set, keyed by property name.

    Returns Promise<void>

  • Waits for all deserialization logic initiated thus far to finish, whether invoked by passing properties into the constructor, or by invoking assignProperties() or assignPropertiesAsync().

    Returns Promise<void>

  • Gets the default value of an object's property.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The property of the object for which to get the default value.

    Returns TProperties[K]

  • Returns a serializable representation of the item.

    Parameters

    • OptionalserializeMode: SerializeMode

      If specified, only properties that are appropriate for the given mode are returned. Otherwise, all properties will be serialized.

    Returns Partial<TProperties>