Class Draft<T>

A class with the implementationm of draft. Use draft to create an instance of this class.

Typeparam

T Data type.

Type Parameters

  • T extends object

Constructors

  • Creates an instance of Draft. Do not use directly, use draft instead.

    Type Parameters

    • T extends object

    Parameters

    • original: T

    Returns Draft<T>

Properties

data: T

Draft data object.

originalData: T

Original data object.

Accessors

  • get isDirty(): boolean
  • Returns true if the draft has changed compared to the original object, false otherwise.

    Returns boolean

Methods

  • Commits current draft changes to the original object.

    Returns void

  • Partially commits current draft changes to the original object. If the path cannot be resolved in either the draft or the original object it will throw. Note that model IDs are checked to be the same when resolving the paths.

    Parameters

    • path: Path

      Path to commit.

    Returns void

  • Returns true if the value at the given path of the draft has changed compared to the original object. If the path cannot be resolved in the draft it will throw. If the path cannot be resolved in the original object it will return true. Note that model IDs are checked to be the same when resolving the paths.

    Parameters

    • path: Path

      Path to check.

    Returns boolean

  • Resets the draft to be an exact copy of the current state of the original object.

    Returns void

  • Partially resets current draft changes to be the same as the original object. If the path cannot be resolved in either the draft or the original object it will throw. Note that model IDs are checked to be the same when resolving the paths.

    Parameters

    • path: Path

      Path to reset.

    Returns void