Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

| * |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Bug Report / [EDGE CASE / ANTIPATTERN] Remove observer error on: August 15, 2008, 12:18:14
Hi,

I report to you a bug when I try to remove a mediator, the observers result is null in the View class and removeObserver method.

This is normal in my case that the return value is null because I update dynamically the listNotificationInterests in the mediator and one of these was not registered. (I remove and insert it to update this list )


I propose a solution to put in the removeObserver method ,

if( !observers ){ //correct null error
   return ;
}

Thanks.

Best regards,
Marc
2  PureMVC Manifold / Bug Report / [ FIXED ] If observer list changes during notification some observers are missed on: June 04, 2008, 05:45:22
hi,

I have a problem with the notifyObservers method in the class View.

I explain, 2 mediators are attach to a same Notification 'CloseView' and when I send it, only one mediator receive it...

It's 'normal' when you analyse the notifyObservers method. When the 'CloseView' notification is received my Mediator is removed from the Facade and by consequence it removed from the observers attribut list (by reference). the var i = 1 and when the next step of 'for' is call observers.length = 1 not 2 (not such as previously) and the second observer is never notified....

//current method
if( observerMap[ notification.getName() ] != null ) {
   var observers:Array = observerMap[ notification.getName() ] as Array;
   for (var i:Number = 0; i < observers.length; i++) {
      var observer:IObserver = observers[ i ] as IObserver;
      observer.notifyObserver( notification );
   }
}

my idea to solve this problen is to clone (deep copy) the observers to unlink the memory reference temporaly.

Someone have an idea about this problem ? And how create a deep copy because the Observer are not correctly copy by the method ObjectUtil.copy(observers);

Best regards,
Marc
Pages: [1]