Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOControl Reference

Table of Contents

EODelayedObserverQueue


Inherits from:
NSObject
Conforms to:
NSObject
(NSObject)
Declared in:
EOControl/EOObserver.h




Class Description


The EODelayedObserverQueue class is a part of EOControl's change tracking mechanism. An EODelayedObserverQueue collects change notifications for observers of multiple objects and notifies them of the changes en masse during the application's run loop, according to their individual priorities. For an overview of the general change tracking mechanism, see "Tracking Enterprise Objects Changes" in the introduction to the EOControl Framework.

EODelayedObserverQueue's style of notification is particularly useful for coalescing and prioritizing multiple changes; the interface layer's EOAssociation classes use it extensively to update Java Client and Application Kit user interfaces, for example. Instead of being told that an object will change, an EODelayedObserver is told that it did change, with a subjectChanged message, as described in the EODelayedObserver class specification. Delayed observation is thus not useful for comparing old and new states, but only for examining the new state. Delayed observation also isn't ordinarily used outside the scope of a Java Client or Application Kit application (in a command line tool or WebObjects application, for example).

The motivation for a delayed change notification mechanism arises mainly from issues in observing multiple objects. Any single change to an observed object typically requires the observer to update some state or perform an action. When many such objects change, it makes no sense to recalculate the new state and perform the action for each object. EODelayedObserverQueue allows these changes to be collected into a single notification. It further orders change notifications according to priorities, allowing observers to be updated in sequence according to dependencies among them. For example, an EOMasterDetailAssociation (EOInterface), which must update its detail EODisplayGroup (EOInterface) according to the selection in the master before any redisplay occurs, has an earlier priority than the default for EOAssociations. This prevents regular EOAssociations from redisplaying old values and then displaying the new values after the EOMasterDetailAssociation updates.

For more information on using EODelayedObserverQueues, see the sections




Constants


In EOObserver.h, EOControl defines an enumeration with the following constant:


Constant Description
EOFlushDelayedObserversRunLoopOrdering Determines when to notify delayed observers during end of event processing.



Method Types


Creating instances
- init
Getting the default queue
+ defaultObserverQueue
Enqueuing and dequeuing observers
- enqueueObserver:
- dequeueObserver:
Sending change notifications
- notifyObserversUpToPriority:
Configuring notification behavior
- runLoopModes
- setRunLoopModes:


Class Methods



defaultObserverQueue

+ (EODelayedObserverQueue *)defaultObserverQueue

Returns the EODelayedObserverQueue that EODelayedObservers use by default.


Instance Methods



dequeueObserver:

- (void)dequeueObserver:(EODelayedObserver *)anObserver

Removes anObserver from the receiver.

See Also: - enqueueObserver:



enqueueObserver:

- (void)enqueueObserver:(EODelayedObserver *)anObserver

Records anObserver to be sent subjectChanged messages. If anObserver's priority is EOObserverPriorityImmediate, it's immediately sent the message and not enqueued. Otherwise anObserver is sent the message the next time notifyObserversUpToPriority: is invoked with a priority later than or equal to anObserver's. Does nothing if anObserver is already recorded.

The first time this method is invoked during the run loop with an observer whose priority isn't EOObserverPriorityImmediate, it registers the receiver to be sent a notifyObserversUpToPriority: message at the end of the run loop, using EOFlushDelayedObserversRunLoopOrdering and the receiver's run loop modes. This causes enqueued observers up to a priority of EOObserverPrioritySixth to be notified automatically during each pass of the run loop.

This method does not retain anObserver. When anObserver is deallocated, it should invoke dequeueObserver: to remove itself from the queue.

See Also: - dequeueObserver:, - priority (EODelayedObserver), - discardPendingNotification (EODelayedObserver), - runLoopModes, - performSelector:target:argument:order:modes: (NSRunLoop class of the Foundation Kit)



init

- (id)init

Initializes a newly allocated EODelayedObserverQueue with NSDefaultRunLoopMode as its only run loop mode. This is the designated initializer for the EODelayedObserverQueue class. Returns self.

notifyObserversUpToPriority:

- (void)notifyObserversUpToPriority:(EOObserverPriority)priority

Sends subjectChanged messages to all of the receiver's enqueued observers whose priority is priority or earlier. This method cycles through the receiver's enqueued observers in priority order, sending each a subjectChanged message and then returning to the very beginning of the queue, in case another observer with an earlier priority was enqueued as a result of the message.

EODelayedObserverQueue invokes this method automatically as needed during the run loop, with a priority of EOObserverPrioritySixth.

See Also: - enqueueObserver:, - priority (EODelayedObserver)



runLoopModes

- (NSArray *)runLoopModes

Returns the receiver's run loop modes.



setRunLoopModes:

- (void)setRunLoopModes:(NSArray *)modes

Sets the receiver's run loop modes to modes, an array of NSString objects representing run loop modes. For more information see the Foundation class NSRunLoop.




Table of Contents