A RangeObserver is used by Arrays to automatically observe all of the objects in a particular range on the array. Whenever any property on one of those objects changes, it will notify its delegate. Likewise, whenever the contents of the array itself changes, it will notify its delegate and possibly update its own registration.
This implementation uses only
SC.Array methods. It can be used on any
object that complies with
SC.Array. You may, however, choose to subclass
this object in a way that is more optimized for your particular design.
Defined in: range_observer.js
- SproutCore 1.0
- create(source, indexSet, target, method, context, isDeep)
- objectPropertyDidChange(the, key, value, rev)
- update(source, indexSet)
Field DetailisRangeObserver Boolean
Instance Method Detail
Configures observing for each item in the current range. Should update the observing array with the list of observed objects so they can be torn down later
Creates a new range observer owned by the source. The
indexSet you pass
must identify the indexes you are interested in observing. The passed
target/method will be invoked whenever the observed range changes.
Note that changes to a range are buffered until the end of a run loop unless a property on the record itself changes.
- source SC.Array
- the source array
- indexSet SC.IndexSet
- set of indexes to observer
- target Object
- the target
- method Function|String
- the method to invoke
- context Object
- optional context to include in callback
- isDeep Boolean
- if YES, observe property changes as well
Remove observers for any objects currently begin observed. This is called whenever the observed range changes due to an array change or due to destroying the observer.
Create subclasses for the RangeObserver. Pass one or more attribute hashes. Use this to create customized RangeObservers if needed for your classes.
- attrs Hash
- one or more attribute hashes
- extended range observer class
Whenever the actual objects in the range changes, notify the delegate then begin observing again. Usually this method will be passed an IndexSet with the changed indexes. The range observer will only notify its delegate if the changed indexes include some of all of the indexes this range observer is monitoring.