Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OberservableUndoableList<T>

An observable list that supports undo/redo.

Type parameters

Hierarchy

  • ObservableList<T>

Implements

  • IObservableList<T>

Index

Constructors

constructor

  • Construct a new undoable observable list.

    Parameters

    • factory: function
        • (value: any): T
        • Parameters

          • value: any

          Returns T

    Returns OberservableUndoableList

Properties

Private _factory

_factory: function

Type declaration

    • (value: any): T
    • Parameters

      • value: any

      Returns T

Private _inCompound

_inCompound: boolean

Private _index

_index: number

Private _isUndoable

_isUndoable: boolean

Private _madeCompoundChange

_madeCompoundChange: boolean

Private _stack

_stack: IListChangedArgs<any>[]

changed

changed: ISignal<ObservableList<T>, IListChangedArgs<T>>

A signal emitted when the list has changed.

Notes

This is a pure delegate to the changedSignal.

Protected internal

internal: T[]

The protected internal array of items for the list.

Notes

Subclasses may access this array directly as needed.

length

length: number

The number of items in the list.

Notes

This is a read-only property.

Static changedSignal

changedSignal: Signal<ObservableList<any>, IListChangedArgs<any>>

A signal emitted when the list has changed.

See also: changed

Accessors

canRedo

  • get (): boolean
  • Whether the object can redo changes.

    Notes

    This is a read-only property.

    Returns boolean

canUndo

  • get (): boolean
  • Whether the object can undo changes.

    Notes

    This is a read-only property.

    Returns boolean

isDisposed

  • get (): boolean
  • Get whether the object is disposed.

    Notes

    This is a read-only property.

    Returns boolean

Methods

Private _copyChange

  • _copyChange(change: IListChangedArgs<T>): IListChangedArgs<any>
  • Copy a change as JSON.

    Parameters

    • change: IListChangedArgs<T>

    Returns IListChangedArgs<any>

Private _copyReplace

  • _copyReplace(change: IListChangedArgs<T>): IListChangedArgs<any>
  • Copy a replace change as JSON.

    Parameters

    • change: IListChangedArgs<T>

    Returns IListChangedArgs<any>

Private _createValue

  • _createValue(data: any): T

Private _createValues

  • _createValues(bundles: any[]): T[]
  • Create a list of cell models from JSON.

    Parameters

    • bundles: any[]

    Returns T[]

Private _onListChanged

  • _onListChanged(list: IObservableList<T>, change: IListChangedArgs<T>): void
  • Handle a change in the list.

    Parameters

    • list: IObservableList<T>
    • change: IListChangedArgs<T>

    Returns void

Private _redoChange

  • _redoChange(change: IListChangedArgs<any>): void
  • Redo a change event.

    Parameters

    • change: IListChangedArgs<any>

    Returns void

Private _undoChange

  • _undoChange(change: IListChangedArgs<any>): void
  • Undo a change event.

    Parameters

    • change: IListChangedArgs<any>

    Returns void

add

  • add(item: T): number
  • Add an item to the end of the list.

    Parameters

    • item: T

      The item to add to the list.

    Returns number

    The index at which the item was added.

Protected addItem

  • addItem(index: number, item: T): number
  • Add an item to the list at the specified index.

    Parameters

    • index: number

      The index at which to add the item. This must be an integer in the range [0, internal.length].

    • item: T

      The item to add at the specified index.

    Returns number

    The index at which the item was added.

    Notes

    This may be reimplemented by subclasses to customize the behavior.

assign

  • assign(items: T[]): T[]
  • Replace the contents of the list with the specified items.

    Parameters

    • items: T[]

      The items to assign to the list.

    Returns T[]

    An array of the previous list items.

    Notes

    This is equivalent to list.replace(0, list.length, items).

beginCompoundOperation

  • beginCompoundOperation(isUndoAble?: boolean): void
  • Begin a compound operation.

    Parameters

    • Optional isUndoAble: boolean

    Returns void

clear

  • clear(): T[]
  • Remove all items from the list.

    Returns T[]

    An array of the items removed from the list.

    Notes

    This is equivalent to list.replace(0, list.length, []).

clearUndo

  • clearUndo(): void

contains

  • contains(item: T): boolean
  • Test whether the list contains a specific item.

    Parameters

    • item: T

      The item of interest.

    Returns boolean

    true if the list contains the item, false otherwise.

dispose

  • dispose(): void
  • Dispose of the resources held by the model.

    Returns void

endCompoundOperation

  • endCompoundOperation(): void

get

  • get(index: number): T
  • Get the item at a specific index in the list.

    Parameters

    • index: number

      The index of the item of interest. If this is negative, it is offset from the end of the list.

    Returns T

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

indexOf

  • indexOf(item: T): number
  • Get the index of the first occurence of an item in the list.

    Parameters

    • item: T

      The item of interest.

    Returns number

    The index of the specified item or -1 if the item is not contained in the list.

insert

  • insert(index: number, item: T): number
  • Insert an item into the list at a specific index.

    Parameters

    • index: number

      The index at which to insert the item. If this is negative, it is offset from the end of the list. In all cases, it is clamped to the bounds of the list.

    • item: T

      The item to insert into the list.

    Returns number

    The index at which the item was inserted.

move

  • move(fromIndex: number, toIndex: number): boolean
  • Move an item from one index to another.

    Parameters

    • fromIndex: number

      The index of the item of interest. If this is negative, it is offset from the end of the list.

    • toIndex: number

      The desired index for the item. If this is negative, it is offset from the end of the list.

    Returns boolean

    true if the item was moved, false otherwise.

Protected moveItem

  • moveItem(fromIndex: number, toIndex: number): boolean
  • Move an item in the list from one index to another.

    Parameters

    • fromIndex: number

      The initial index of the item. This must be an integer in the range [0, internal.length).

    • toIndex: number

      The desired index for the item. This must be an integer in the range [0, internal.length).

    Returns boolean

    true if the item was moved, false otherwise.

    Notes

    This may be reimplemented by subclasses to customize the behavior.

redo

  • redo(): void

remove

  • remove(item: T): number
  • Remove the first occurrence of a specific item from the list.

    Parameters

    • item: T

      The item to remove from the list.

    Returns number

    The index occupied by the item, or -1 if the item is not contained in the list.

removeAt

  • removeAt(index: number): T
  • Remove the item at a specific index.

    Parameters

    • index: number

      The index of the item of interest. If this is negative, it is offset from the end of the list.

    Returns T

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

Protected removeItem

  • removeItem(index: number): T
  • Remove the item from the list at the specified index.

    Parameters

    • index: number

      The index of the item to remove. This must be an integer in the range [0, internal.length).

    Returns T

    The item removed from the list.

    Notes

    This may be reimplemented by subclasses to customize the behavior.

replace

  • replace(index: number, count: number, items: T[]): T[]
  • Replace items at a specific location in the list.

    Parameters

    • index: number

      The index at which to modify the list. If this is negative, it is offset from the end of the list. In all cases, it is clamped to the bounds of the list.

    • count: number

      The number of items to remove at the given index. This is clamped to the length of the list.

    • items: T[]

      The items to insert at the specified index.

    Returns T[]

    An array of the items removed from the list.

Protected replaceItems

  • replaceItems(index: number, count: number, items: T[]): T[]
  • Replace items at a specific location in the list.

    Parameters

    • index: number

      The index at which to modify the list. This must be an integer in the range [0, internal.length].

    • count: number

      The number of items to remove from the list. This must be an integer in the range [0, internal.length].

    • items: T[]

      The items to insert at the specified index.

    Returns T[]

    An array of the items removed from the list.

    Notes

    This may be reimplemented by subclasses to customize the behavior.

set

  • set(index: number, item: T): T
  • Set the item at a specific index.

    Parameters

    • index: number

      The index of interest. If this is negative, it is offset from the end of the list.

    • item: T

      The item to set at the index.

    Returns T

    The item which occupied the index, or undefined if the index is out of range.

Protected setItem

  • setItem(index: number, item: T): T
  • Set the item at a specific index in the list.

    Parameters

    • index: number

      The index of interest. This must be an integer in the range [0, internal.length).

    • item: T

      The item to set at the index.

    Returns T

    The item which previously occupied the specified index.

    Notes

    This may be reimplemented by subclasses to customize the behavior.

slice

  • slice(start?: number, end?: number): T[]
  • Get a shallow copy of a portion of the list.

    Parameters

    • Optional start: number

      The start index of the slice, inclusive. If this is negative, it is offset from the end of the list. If this is not provided, it defaults to 0. In all cases, it is clamped to the bounds of the list.

    • Optional end: number

      The end index of the slice, exclusive. If this is negative, it is offset from the end of the list. If this is not provided, it defaults to length. In all cases, it is clamped to the bounds of the list.

    Returns T[]

    A new array containing the specified range of items.

undo

  • undo(): void

Generated using TypeDoc