bindable.Collection


Extends bindable.Object

bindable.Collection operates like arrays, except they're watchable if anything changes.

Installation

npm install bindable --save-exact

Collection(source)

The constructor

source

The source of the collection. This is an array.

reset(source)

Resets the source of the collection. You can also do this by calling set('source', array)

indexOf(item)

returns the index of an item

value at(index)

returns an item at the given index

each(fn)

iterates through the collection. similar to array.forEach.

push(values...)

pushes items to the end of the collection.

unshift(values...)

unshifts items to the beginning of the collection.

splice(index, count[, newValues...])

removes items from the collection

value pop()

pops the last item off the collection

value shift()

removes the first item from the collection

Events

  • insert - emitted when items are inserted
  • update - emitted when the collection is updated
  • reset - emitted when the source has been reset
  • remove - emitted when items have been removed