Interface IObservableUndoableList<T>

An observable list that supports undo/redo.

interface IObservableUndoableList<T> {
    canRedo: boolean;
    canUndo: boolean;
    changed: ISignal<
        IObservableUndoableList<T>,
        IObservableList.IChangedArgs<T>,
    >;
    isDisposed: boolean;
    length: number;
    type: "List";
    "[iterator]"(): Iterator<T, any, undefined>;
    beginCompoundOperation(isUndoAble?: boolean): void;
    clear(): void;
    clearUndo(): void;
    dispose(): void;
    endCompoundOperation(): void;
    get(index: number): T;
    insert(index: number, value: T): void;
    insertAll(index: number, values: Iterable<T>): void;
    move(fromIndex: number, toIndex: number): void;
    push(value: T): number;
    pushAll(values: Iterable<T>): number;
    redo(): void;
    remove(index: number): undefined | T;
    removeRange(startIndex: number, endIndex: number): number;
    removeValue(value: T): number;
    set(index: number, value: T): void;
    undo(): void;
}

Type Parameters

  • T

Hierarchy (View Summary)

Implemented by

Properties

canRedo: boolean

Whether the object can redo changes.

canUndo: boolean

Whether the object can undo changes.

A signal emitted when the list has changed.

isDisposed: boolean

Test whether the object has been disposed.

This property is always safe to access.

length: number

The length of the list.

This is a read-only property.

type: "List"

The type of this object.

Methods

  • Begin a compound operation.

    Parameters

    • OptionalisUndoAble: boolean

      Whether the operation is undoable. The default is false.

    Returns void

  • Dispose of the resources held by the object.

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

  • Insert a value into the list at a specific index.

    Parameters

    • index: number

      The index at which to insert the value.

    • value: T

      The value to set at the specified index.

      Linear.

      No changes.

      The index will be clamped to the bounds of the list.

      An index which is non-integral.

    Returns void

  • Insert a set of items into the list at the specified index.

    Parameters

    • index: number

      The index at which to insert the values.

    • values: Iterable<T>

      The values to insert at the specified index.

      Linear.

      No changes.

      The index will be clamped to the bounds of the list.

      An index which is non-integral.

    Returns void

  • Move a value from one index to another.

    Parameters

    • fromIndex: number

      The index of the element to move.

    • toIndex: number

      The index to move the element to.

      Constant.

      Iterators pointing at the lesser of the fromIndex and the toIndex and beyond are invalidated.

      A fromIndex or a toIndex which is non-integral.

    Returns void

  • Remove and return the value at a specific index.

    Parameters

    • index: number

      The index of the value of interest.

    Returns undefined | T

    The value at the specified index, or undefined if the index is out of range.

    Constant.

    Iterators pointing at the removed value and beyond are invalidated.

    An index which is non-integral.

  • Remove a range of items from the list.

    Parameters

    • startIndex: number

      The start index of the range to remove (inclusive).

    • endIndex: number

      The end index of the range to remove (exclusive).

    Returns number

    The new length of the list.

    Linear.

    Iterators pointing to the first removed value and beyond are invalid.

    A startIndex or endIndex which is non-integral.

  • Remove the first occurrence of a value from the list.

    Parameters

    • value: T

      The value of interest.

    Returns number

    The index of the removed value, or -1 if the value is not contained in the list.

    Linear.

    Iterators pointing at the removed value and beyond are invalidated.

  • Set the value at the specified index.

    Parameters

    • index: number

      The positive integer index of interest.

    • value: T

      The value to set at the specified index.

      Constant.

      No changes.

      An index which is non-integral or out of range.

    Returns void