Add a listener for state changes to a specific record.
The store-issued record id (create).
Fold a set of writes into an existing commit, by id, without a log entry.
An amend is how derived data lands: what a calculation produced for a commit, or a listener registration that must never read as an edit. It is not a step in the history:
The writes read from and land in the named commit's own snapshot, whichever commit the store is at, and later snapshots are not touched: a later commit answers for its own writes. That is the fold for a result computed against a snapshot, a calculation's answer to a request made at that commit. A target that is not the current commit notifies no state listener; the current state did not change. A target the store no longer has folds into the current commit. Called while a transaction is open, the callback runs inside it and its writes land wherever that operation's commit does: an amend cannot re-target an operation in progress.
Begin a transaction using the current commit.
Optionaloptions: string | StoreOperationOptions<any>OptionalonClose: CloseCallbackCreate a record, minting its stable state id. The opposite of remove.
Optionalinitial: Readonly<STATE>
The initial state to seed, if any.
The store-issued state id — the model's identity (ITransactional.getId) and the key for every other store operation.
Used by ITransactional objects. Both to expose doBatch and to implement
their own internal transactions.
Optionaloptions: StoreOperationOptions<any>OptionalonClose: CloseCallbackReturns the total number of commits.
Returns the current commit.
OptionalincludePending: boolean
If false, always the last completed commit — a stable log id even
while a transaction is open. default true.
The innermost open transaction: the one a transaction begun now would nest in.
null if none is open. The root of the operation is getPendingTransaction.
Returns the last commits of commits.
The commit id to start from.
Optionalmax: number
The maximum number of commits to return. default 100.
The root transaction of the operation that is open.
Returns the state a record held as of a commit.
The commit whose snapshot to read.
The store-issued record id (create).
The commit's snapshot, not the current state: what a derived write that lands late - a
calculation's compile landing in the commit that entered a formula (amend) - reads
so that it sees the inputs as they were when the operation was made, whatever has changed
since. undefined when the store no longer holds the commit, or the record did not exist
at it.
Returns the newest committed point of the history — the tip.
Unlike getCurrentCommit the tip does not move on restore/revert; the segment from the current commit forward to the tip is the redo history. Together with getLog this is the pull primitive for "what happened since commit X": walk the log from the tip back to the last id you saw. Listener events are dispatched on a deferred tick, so a consumer whose next action depends on being current should pull, not wait.
Returns the version id of a record at the current commit.
The store-issued record id (create).
The version id, or 0 if the record has never been committed.
Ids come from a single store-wide sequence bumped once per commit: a record's id increases on every committed write (but is not sequential per record), and records written in the same commit share an id. Because records are immutable, a restore/revert repoints the store and this reports the id of the snapshot the store is currently at; ids themselves are never reused. Reads during an open transaction report the last committed id — pending (uncommitted) writes have no id yet.
Returns true while the open operation is an amend of a commit other than the one
the store is at.
Its writes land in that commit's snapshot alone, and the current state does not change. So anything made inside it that is not versioned by this store - a resource held outside it, once for every snapshot - would exist where the current snapshot has no record of it. Code that makes such a thing asks this first.
Returns true if there is an open transaction.
Physically remove a record from the store. Not undoable. The opposite of create.
The store-issued record id (create).
A flag indicating if anything was removed.
Fires IStateListener.onClose and detaches the record's state listeners, then
purges the record from every snapshot (history included) and any open transactions.
For the logical, undoable flavor use the model's delete (a state flag).
Set the state to a previous history point.
Optionaloptions: RestoreOptionsRevert is similar to restore in that it moves the state, but it replays the commit's intents in reverse - an undo lands where the operation began rather than where it ended.
Optionaloptions: RestoreOptions
Add a listener to listen for changes.