Skip to main content
Version: v1

OrderedEditSet Interface

An ordered set of Edits associated with a SharedTree. Supports fast lookup of edits by ID and enforces idempotence. Edits are virtualized, however, edits added during the current session are guaranteed to be available synchronously.

Signature

/** @sealed */
export interface OrderedEditSet<TChange = unknown>

Type Parameters

Parameter Default Description
TChange unknown

Properties

Property Type Description
editIds readonly EditId[] The edit IDs of all edits in the log.
length number The length of this OrderedEditSet.

Methods

Method Return Type Description
getEditAtIndex(index) Promise<Edit<TChange>>
getEditInSessionAtIndex(index) Edit<TChange>
getIdAtIndex(index) EditId
getIndexOfId(editId) number
tryGetEdit(editId) Promise<Edit<TChange> | undefined>
tryGetIndexOfId(editId) number | undefined

Property Details

editIds

The edit IDs of all edits in the log.

Signature

readonly editIds: readonly EditId[];

Type: readonly EditId[]

length

The length of this OrderedEditSet.

Signature

readonly length: number;

Type: number

Method Details

getEditAtIndex

Signature

getEditAtIndex(index: number): Promise<Edit<TChange>>;

Parameters

Parameter Type Description
index number

Returns

the edit at the given index within this OrderedEditSet.

Return type: Promise<Edit<TChange>>

getEditInSessionAtIndex

Signature

getEditInSessionAtIndex(index: number): Edit<TChange>;

Parameters

Parameter Type Description
index number

Returns

the edit at the given index. Must have been added to the log during the current session.

Return type: Edit<TChange>

getIdAtIndex

Signature

getIdAtIndex(index: number): EditId;

Parameters

Parameter Type Description
index number

Returns

the id of the edit at the given index within this 'OrderedEditSet'.

Return type: EditId

getIndexOfId

Signature

getIndexOfId(editId: EditId): number;

Parameters

Parameter Type Description
editId EditId

Returns

the index of the edit with the given editId within this OrderedEditSet.

Return type: number

tryGetEdit

Signature

tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;

Parameters

Parameter Type Description
editId EditId

Returns

the Edit associated with the EditId or undefined if there is no such edit in the set.

Return type: Promise<Edit<TChange> | undefined>

tryGetIndexOfId

Signature

tryGetIndexOfId(editId: EditId): number | undefined;

Parameters

Parameter Type Description
editId EditId

Returns

the index of the edit with the given editId within this OrderedEditSet, or undefined if no such edit exists.

Return type: number | undefined