On 05/24/2012 07:02 AM, Stefan Ram wrote:
> When a controller request many little changes of the model,
> it might make sense to update the screen not after every little
> update but only after the last update of the containing operation.
>
> However, the model or view do not know after a little model
> update whether there are more updates to come, so they
> cannot decide whether to update now or later. Also the model
> does not know whether an observer is a View or some other
> entity that possibly might need to be notified of each
> little update.
>
> How is this usually handled?
>
> I see one possibility to write the controller code as, e.g.,
>
> model.startCompoundChange();
> while( final Example example : container )model.add( example );
> model.endCompoundChange();
>
> Where »startCompoundChange« and »endCompoundChange« will then
> be broadcast to all observers of the model and the observers
> now are free to only refresh the display after an »endCompoundChange«.
>
> Another solution would be to send lightweight update
> notifications to the View which then will start a timer to
> update after, say, 0.1 s, ignoring all additional update
> notifications for the same model that arive during that
> time. But this might feel more sluggish to the end user,
> because the visual feedback is delayed.
>
See Cocoa's NSNotificationQueue.
Some discussion is here:
<
http://www.mikeash.com/pyblog/friday-qa-2010-01-08-nsnotificationqueue.html>