Skip to main content
Version: v1

GenericTransaction Class

A mutable transaction for applying sequences of changes to a TreeView. Allows viewing the intermediate states.

Contains necessary state to apply changes within an edit to a TreeView.

May have any number of changes applied to make up the edit. Use close to complete the transaction, returning the array of changes and an EditingResult showing the results of applying the changes as an Edit to the initial TreeView (passed to the constructor).

No data outside the Transaction is modified by Transaction: the results from close must be used to actually submit an Edit.

Signature

export declare class GenericTransaction

Constructors

Constructor Description
(constructor)(view, policy) Create and open an edit of the provided TreeView. After applying 0 or more changes, this editor should be closed via close().

Properties

Property Type Description
before RevisionView
changes readonly ChangeInternal[] The status code of the most recent attempted change.
isOpen boolean Whether or not this transaction has been closed via close()
status EditStatus The status code of the most recent attempted change.
steps readonly ReconciliationChange[] The status code of the most recent attempted change.
view TransactionView The most up-to-date TreeView for this edit. This is the state of the tree after all changes applied so far.

Methods

Method Return Type Description
applyChange(change, path) this Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to apply.
applyChanges(changes, path) this A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply, the remaining changes in changes will be ignored.
close() EditingResult

Constructor Details

(constructor)

Create and open an edit of the provided TreeView. After applying 0 or more changes, this editor should be closed via close().

Signature

constructor(view: RevisionView, policy: GenericTransactionPolicy);

Parameters

Parameter Type Description
view RevisionView the TreeView at which this edit begins. The first change will be applied against this view.
policy GenericTransactionPolicy

Property Details

before

Signature

protected readonly before: RevisionView;

Type: RevisionView

changes

The status code of the most recent attempted change.

Signature

get changes(): readonly ChangeInternal[];

Type: readonly ChangeInternal[]

isOpen

Whether or not this transaction has been closed via close()

Signature

get isOpen(): boolean;

Type: boolean

status

The status code of the most recent attempted change.

Signature

get status(): EditStatus;

Type: EditStatus

steps

The status code of the most recent attempted change.

Signature

get steps(): readonly ReconciliationChange[];

Type: readonly ReconciliationChange[]

view

The most up-to-date TreeView for this edit. This is the state of the tree after all changes applied so far.

Signature

get view(): TransactionView;

Type: TransactionView

Method Details

applyChange

Attempt to apply the given change as part of this edit. This method should not be called if a previous change in this edit failed to apply.

Signature

applyChange(change: ChangeInternal, path?: ReconciliationPath): this;

Parameters

Parameter Modifiers Type Description
change ChangeInternal the change to apply
path optional ReconciliationPath the reconciliation path for the change.

Returns

this

Return type: this

applyChanges

A helper to apply a sequence of changes. Changes will be applied one after the other. If a change fails to apply, the remaining changes in changes will be ignored.

Signature

applyChanges(changes: Iterable<ChangeInternal>, path?: ReconciliationPath): this;

Parameters

Parameter Modifiers Type Description
changes Iterable<ChangeInternal> the sequence of changes to apply.
path optional ReconciliationPath the reconciliation path for the first change.

Returns

this

Return type: this

close

Signature

close(): EditingResult;

Returns

the final EditStatus and TreeView after all changes are applied.

Return type: EditingResult