Array#addArrayObserver()

addArrayObserver (target, opts) Ember.Arraypublic

Defined in packages/ember-runtime/lib/mixins/array.js:460

Adds an array observer to the receiving array. The array observer object normally must implement two methods:

  • arrayWillChange(observedObj, start, removeCount, addCount) - This method will be called just before the array is modified.
  • arrayDidChange(observedObj, start, removeCount, addCount) - This method will be called just after the array is modified.

Both callbacks will be passed the observed object, starting index of the change as well as a count of the items to be removed and added. You can use these callbacks to optionally inspect the array during the change, clear caches, or do any other bookkeeping necessary.

In addition to passing a target, you can also include an options hash which you can use to override the method names that will be invoked on the target.

Parameters:

target Object
The observer object.
opts Object
Optional hash of configuration options including `willChange` and `didChange` option.

Returns:

Ember.Array
receiver
doc_EmberJs
2016-11-30 16:48:33
Comments
Leave a Comment

Please login to continue.