Trace hooks for Avenx Rewind.
A value that changes back on its own is the single most confusing thing a trace can contain. Without a node for it, a rewind shows up as a run of writes with no cause — exactly the situation Trace exists to eliminate.
The node is opened around the rewind, so every restoring write lands underneath it as an ordinary write and the causal tree reads:
▸ click <button.qty-inc> CartItem └─ action CartItem.incQty() └─ rewind CartItem.incQty — 3 restored [safe] ├─ write cart.items.0.qty 2 → 1 └─ write CartItem.busy true → false
Kept out of journal.js for the same reason trace/reactive.js is kept out
of proxyHandler.js: the reactive system should not import the recorder.
- Source:
Methods
(static) traceRewindOutcome(id, outcome) → {void}
Records what the rewind managed to do, on the node opened for it.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | null | The node id |
outcome |
object | What |
- Source:
Returns:
- Type
- void
(static) traceRewindStart(frame) → {Object}
Opens a rewind node and makes it the causal parent of the restoring writes.
Callers must guard with tracer.on and pass the returned token to
tracer.leave() in a finally.
Parameters:
| Name | Type | Description |
|---|---|---|
frame |
object | The journal frame about to be played backwards. |
- Source:
Returns:
The restore token for
tracer.leave, and the node's id so the outcome can be filled in later.
{token: -1, id: null} when tracing is off.
- Type
- Object