Class: Draft<T>
A class with the implementationm of draft.
Use draft to create an instance of this class.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends object | Data type. |
Constructors
Constructor
new Draft<T>(original): Draft<T>;
Creates an instance of Draft.
Do not use directly, use draft instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
original | T | - |
Returns
Draft<T>
Properties
data
readonly data: T;
Draft data object.
originalData
readonly originalData: T;
Original data object.
Accessors
isDirty
Get Signature
get isDirty(): boolean;
Returns true if the draft has changed compared to the original object, false otherwise.
Returns
boolean
Methods
commit()
commit(): void;
Commits current draft changes to the original object.
Returns
void
commitByPath()
commitByPath(path): 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
| Parameter | Type | Description |
|---|---|---|
path | Path | Path to commit. |
Returns
void
isDirtyByPath()
isDirtyByPath(path): boolean;
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
| Parameter | Type | Description |
|---|---|---|
path | Path | Path to check. |
Returns
boolean
reset()
reset(): void;
Resets the draft to be an exact copy of the current state of the original object.
Returns
void
resetByPath()
resetByPath(path): 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
| Parameter | Type | Description |
|---|---|---|
path | Path | Path to reset. |
Returns
void