Class: Journal

lib/core/reactive/journal~Journal()

The transaction stack.

A singleton for the same reason the tracer is one: the reactive system is module-scoped, so a per-application journal would have to be threaded through every trap.

Constructor

new Journal()

Constructs the idle journal installed at import time.

Source:

Members

active :boolean

Hot-path flag. Read by every mutation site, so it is a plain own property rather than a getter over frames.length.

Type:
  • boolean
Source:

defaults :Object

Project defaults, installed by the application at startup.

Type:
  • Object
Source:

frames :Array:.<JournalFrame:>

Frames whose dynamic extent is currently executing, innermost last.

Type:
  • Array:.<JournalFrame:>
Source:

Methods

(frame, causeopt) → {void}

Rewinds a frame and reports whatever it could not restore.

Parameters:
Name Type Attributes Description
frame JournalFrame

The frame to play backwards.

cause any <optional>

The failure that triggered the rewind, carried on an AVX_R29 raised under the abort policy so it is not lost.

Source:
Returns:
Type
void

begin(optionsopt) → {JournalFrame}

Opens a frame and makes it the recording target.

Parameters:
Name Type Attributes Description
options object <optional>

Frame options; see JournalFrame.

Source:
Returns:

The opened frame.

Type
JournalFrame

close(frame) → {void}

Closes a frame's dynamic extent.

Truncating to the frame's depth rather than popping blindly means an exception that unwound past a close cannot leave the journal recording into a frame that has already finished.

Parameters:
Name Type Description
frame JournalFrame

The frame to close.

Source:
Returns:
Type
void

configure(optionsopt) → {void}

Applies project-level Rewind configuration.

Parameters:
Name Type Attributes Description
options object <optional>

rewind from avenx.config.json.

Properties
Name Type Attributes Description
onConflict string <optional>

Default conflict policy.

maxSnapshotItems number <optional>

Default collection ceiling.

Source:
Returns:
Type
void

current() → {JournalFrame|null}

The frame currently recording, or null.

Source:
Returns:

The innermost open frame.

Type
JournalFrame | null

recordCollection(target, handler, fallback) → {void}

Takes a collection savepoint in the open frame.

Parameters:
Name Type Description
target object

The raw array, Map or Set.

handler object

The ProxyHandlerFactory that owns this target.

fallback string

What to call it when it has no resolvable path.

Source:
Returns:
Type
void

recordDelete(target, key, oldValue, existed, handler) → {void}

Records a deletion into the open frame.

Parameters:
Name Type Description
target object

The raw object.

key string | number

The deleted key.

oldValue any

The value it held.

existed boolean

Whether the key was there to begin with.

handler object

The ProxyHandlerFactory that owns this target.

Source:
Returns:
Type
void

recordWrite(target, key, oldValue, newValue, existed, handler) → {void}

Records a property write into the open frame.

Parameters:
Name Type Description
target object

The raw object that was mutated.

key string | number

The mutated key.

oldValue any

The value before the mutation.

newValue any

The value after it.

existed boolean

Whether the key was an own property beforehand.

handler object

The ProxyHandlerFactory that owns this target.

Source:
Returns:
Type
void

reset() → {void}

Drops every open frame. Used by tests and by teardown.

Source:
Returns:
Type
void

run(spec, fn) → {T}

Runs a function as a transaction.

The outcome is the function's own: it commits by returning, and rewinds by throwing or by handing back a promise that rejects. Nothing else is introduced, because an action already has both of those.

A transaction opened while another is recording joins it instead of opening a second frame. That is what makes an atomic bridge action called from an atomic component action undo exactly once.

Parameters:
Name Type Description
spec object

{owner, name, onConflict}.

fn function

The action body.

Source:
Returns:

Whatever fn returned.

Type
T