Class: SC.RangeObserver
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
- Since:
- SproutCore 1.0
Field Summary
Instance Methods
- beginObserving()
- create(source, indexSet, target, method, context, isDeep)
- destroy(source)
- endObserving()
- extend(attrs)
- objectPropertyDidChange(the, key, value, rev)
- rangeDidChange(changes)
- update(source, indexSet)
Field Detail
isRangeObserver BooleanInstance 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
- Returns:
- SC.RangeObserver
- receiver
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.
- Parameters:
- 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
- Returns:
- SC.RangeObserver
- instance
- Parameters:
- source SC.Array
- the source array
- Returns:
- SC.RangeObserver
- receiver
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.
- Returns:
- SC.RangeObserver
- receiver
Create subclasses for the RangeObserver. Pass one or more attribute hashes. Use this to create customized RangeObservers if needed for your classes.
- Parameters:
- attrs Hash
- one or more attribute hashes
- Returns:
- SC.RangeObserver
- extended range observer class
- Parameters:
- the Object
- object that changed
- key String
- the property that changed
- value Null
- No longer used
- rev Number
- The revision of the change
- Returns:
- SC.RangeObserver
- receiver
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.
- Parameters:
- changes SC.IndexSet
- optional set of changed indexes
- Returns:
- SC.RangeObserver
- receiver
Updates the set of indexes the range observer applies to. This will stop observing the old objects for changes and start observing the new objects instead.
- Parameters:
- source SC.Array
- the source array
- indexSet SC.IndexSet
- The index set representing the change
- Returns:
- SC.RangeObserver
- receiver