Class: JournalFrame

lib/core/reactive/journal.JournalFrame(optionsopt)

One transaction's record of what it changed.

Entries are kept in first-touch order and replayed in reverse, so a key written three times is restored once, to the value it had before the transaction started.

Constructor

new JournalFrame(optionsopt)

Parameters:
Name Type Attributes Description
options object <optional>

Frame options.

Properties
Name Type Attributes Description
owner string <optional>

The component or bridge that owns the action.

name string <optional>

The action name, used in diagnostics.

onConflict string <optional>

The conflict policy for this frame.

maxSnapshotItems number <optional>

Collection snapshot ceiling.

Source:

Members

collectionIndex :Map:.<object:, object:>

Type:
  • Map:.<object:, object:>
Source:

collections :Array:.<object:>

Collection savepoints, in first-touch order.

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

empty

Whether the frame recorded anything at all.

Source:

entries :Array:.<object:>

Property writes, in first-touch order.

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

index :Map:.<object:, Map:.<(string:|number:), object:>>

Target to key to entry, for deduplication.

Type:
  • Map:.<object:, Map:.<(string:|number:), object:>>
Source:

maxSnapshotItems :number

Type:
  • number
Source:

name :string

Type:
  • string
Source:

onConflict :string

Type:
  • string
Source:

owner :string

Type:
  • string
Source:

settled :boolean

Type:
  • boolean
Source:

unrewindable :Array:.<string:>

Paths this frame knows it cannot restore, discovered while recording.

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

Methods

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

Takes a savepoint of a collection before it is mutated.

An array method, a Map.set or a Set.add has no single before-and-after pair to journal — splice can move every element at once — so the whole container is copied, once, the first time the transaction touches it.

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.

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.

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

rewind() → {Object}

Plays the frame backwards.

Property writes are restored through the handler that recorded them, so a rewind wakes watchers exactly as the original write did. Collections are restored in place and then triggered, because there is no single key whose assignment would describe the change.

Source:
Returns:

What the rewind managed to do.

Type
Object