Options
All
  • Public
  • Public/Protected
  • All
Menu

Stores values in sorted order based on a sort function. Use sync to track an existing collection and present it as sorted.

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

Properties

bindingEvent

bindingEvent: GeocortexEvent

The {@link geocortex.framework.events.Event} that is fired when this collection is modified.

throttleDelay

throttleDelay: number

An optional throttleDelay parameter that defines the delay between throttling operations (in milliseconds).

throttledOperations

throttledOperations: ThrottledOperation[]

An array containing all the throttled binding operations currently active on this collection, if throttling is enabled.

useThrottling

useThrottling: boolean

Whether or not to perform throttled binding on this collection. If set to true, data-binding operations across this collection will be performed asynchronously to avoid blocking the UI thread.

Methods

addItem

  • addItem(item: T): void

addItems

  • addItems(items: T[]): void
  • The array of items being added need not be sorted.

    Parameters

    • items: T[]

    Returns void

bind

  • bind(scope: any, handler: function): string
  • Binds a handler to the binding event. This handler will be executed whenever the value of the collection is modified Through an ObservableCollection call. This method returns a subscription token that can be used to unsubscribe the handler.

    Parameters

    • scope: any

      The scope to execute the handler in. This will the meaning of 'this' inside of the handler when it is called.

    • handler: function

      The handler to execute when the Observable changes.

    Returns string

clear

  • clear(): void
  • Clears the collection and triggers the binding event.

    Returns void

contains

  • contains(item: T): boolean
  • Checks whether this collection contains a specific item.

    Parameters

    • item: T

      The item to check for.

    Returns boolean

equals

get

  • get(): T[]
  • Gets the raw underlying collection.

    Returns T[]

getAt

  • getAt(index: number): T
  • Tries to get an item from the underlying collection at a given index.

    Parameters

    • index: number

    Returns T

getItems

  • getItems(): T[]

getLength

  • getLength(): number

getRange

  • getRange(begin: number, end?: number): T[]
  • Returns items, given a specific range. Works like Array.slice, except end is inclusive.

    Parameters

    • begin: number

      The beginning of the range to fetch.

    • Optional end: number

      The end of the rang to fetch (inclusive).

    Returns T[]

getSortFunction

  • getSortFunction(): function
  • Returns function

      • (left: T, right: T): number
      • Parameters

        • left: T
        • right: T

        Returns number

indexOf

  • indexOf(item: T): number
  • Determines the index of the specified item in the collection.

    Parameters

    • item: T

      The item to get the index of.

    Returns number

insertItem

  • insertItem(index: number, item: T): void

insertItems

  • insertItems(index: number, items: T[]): void

isEmpty

  • isEmpty(): boolean
  • Checks whether this collection contains any items

    Returns boolean

length

  • length(): number

once

  • once(scope: any, handler: Function): string
  • Binds a handler the the binding event only once. The handler will only be executed the next time the ObservableCollection is updated. This method returns a subscription token that can be used to unsubscribe the handler.

    Parameters

    • scope: any

      The scope to execute the handler in.

    • handler: Function

      The handler to execute when the Observable changes.

    Returns string

pulse

  • pulse(): void
  • Fires the binding event twice, simulating a clear and and append of the entire collection back to its original state. See Observable.

    Returns void

removeAt

  • removeAt(index: number): void
  • Removes the item at the specified index and triggers the binding event. If the index is not valid for this collection, then nothing happens.

    Parameters

    • index: number

      The index of the item to remove.

    Returns void

removeItem

  • removeItem(obj: T): void
  • Removes an object from the collection and triggers the binding event.

    Parameters

    • obj: T

      The object instance to remove.

    Returns void

removeRange

  • removeRange(from: number, to?: number): void
  • Removes a range of items from the collection and fires the binding event accordingly.

    Parameters

    • from: number

      The index to remove from.

    • Optional to: number

      The index to remove to. This is inclusive.

    Returns void

removeSync

  • removeSync(): void
  • Removes the event subscriptions that were created when sync() was called. This effectively unbinds the synchronization that exists between this ObservableCollection and another ObservableCollection.

    Returns void

removeWhere

  • removeWhere(callback: function): void
  • Removes all items from this ObservableCollection where the supplied callback function returns a truthy value.

    Parameters

    • callback: function
        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns void

set

  • set(newCollection: T[]): void

setSortFunction

  • setSortFunction(sorter: function): void
  • Change the sorting function and trigger a resort of the collection. If left should come before right then the sort function should return < 0. If left and right are equal the sort function should return 0. If left should come after right the sort function should return > 0.

    Parameters

    • sorter: function
        • (left: T, right: T): number
        • Parameters

          • left: T
          • right: T

          Returns number

    Returns void

sync

  • Track changes to the given ObservableCollection and present them in this collection in sorted order.

    Parameters

    Returns void

unbind

  • unbind(token: string): boolean
  • Unbinds a binding subscription, given a valid subscription token received from a call to bind().

    Parameters

    • token: string

      The token representing the previously added subscription handler.

    Returns boolean