trakked 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -428,7 +428,7 @@ const invoice = tracker.construct(() => new InvoiceModel(tracker));
|
|
|
428
428
|
| `state` | `ObjectState` | Computed DB operation required at save time |
|
|
429
429
|
| `_committedState` | `ObjectState` | The persisted state. Defaults to `Unchanged`. Pass `initialState` to the constructor to override |
|
|
430
430
|
| `destroy()` | `void` | Removes this model from the tracker |
|
|
431
|
-
| `onCommitted()` | `void` | Called automatically by `tracker.onCommit()` —
|
|
431
|
+
| `onCommitted()` | `void` | Called automatically by `tracker.onCommit()` — transitions `_committedState` and records the inverse in the undo stack so that undoing a commit restores the correct state |
|
|
432
432
|
|
|
433
433
|
---
|
|
434
434
|
|
|
@@ -449,6 +449,16 @@ import { ObjectState } from 'trakked';
|
|
|
449
449
|
|
|
450
450
|
`Edited` is **derived**: when `_committedState === Unchanged` and the object has unsaved property changes (`isDirty === true`), `state` returns `Edited`. It is never stored directly.
|
|
451
451
|
|
|
452
|
+
**Undo of a committed save:**
|
|
453
|
+
|
|
454
|
+
`tracker.onCommit()` records the state transition in the undo stack. Undoing past a commit reverses the server operation:
|
|
455
|
+
|
|
456
|
+
| Committed operation | State after undo | Required server operation |
|
|
457
|
+
|---|---|---|
|
|
458
|
+
| INSERT (`New`) | `Deleted` | DELETE |
|
|
459
|
+
| UPDATE (`Edited`) | `Edited` (with pre-edit values) | UPDATE |
|
|
460
|
+
| DELETE (`Deleted`) | `New` | INSERT |
|
|
461
|
+
|
|
452
462
|
**Loading from DB:**
|
|
453
463
|
|
|
454
464
|
Objects default to `Unchanged`, so no extra setup is needed. Property values set inside the constructor are suppressed by `tracker.construct()`:
|