Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
/** The vector array that contains the list of notifications that should be sent to the application. **/ private var _vNotifications:Vector.<INotification> = new Vector.<INotification>(); /** The notitfcation that is currently in the process of being sent. **/ private var _noteCurrent:INotification; /** * Override notifyObservers() so notifications that are sent to this method are completely sent before a different notfication is sent. */ override public function notifyObservers(notification:INotification): void { if(observerMap[notification.getName()] != null ) { _vNotifications.push(notification); if(_noteCurrent != null){ //If there is a previous notification still being sent, then do not proceed to notify the next notifcation //until the previous notification has completely been sent to all observers. return; } _noteCurrent = notification; super.notifyObservers(notification); //once the notification has been sent, remove the notification from _vNotifications var iLength:int = _vNotifications.length; for(var i:int = 0; i<=iLength-1 && iLength>0; i++){ if(_vNotifications[i] == notification){ //most likely this will be the 1st item in the Vector Array _vNotifications.splice(i,1); break; } } _noteCurrent = null; //if there are still notifications in _vNotifications, then notify the observers of the next 1st notification within the vector array if(_vNotifications.length > 0){ notifyObservers(_vNotifications.shift()); } } }
Do you see something wrong with wanting that a notification is received by all observers before subsequent notifications are received?
Should observers of the notification system receive notifications that were not before other notifications?
What are the use cases when one would want a later notification to be received by an earlier notification?
These observers only react to the ENTER key if their sprite is visible.