Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IObservableList<T>

A sequence container which can be observed for changes.

Type parameters

  • T

Hierarchy

  • IObservableList

Implemented by

Index

Properties

changed

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

A signal emitted when the list has changed.

length

length: number

The number of items in the list.

Notes

This is a read-only property.

Methods

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.

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).

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, []).

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.

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.

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.

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.

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.

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.

Generated using TypeDoc