Title: Remove Mediator Bug Post by: puremvc on December 08, 2007, 04:41:41 Hi Folks,
View.removeMediator() is now responsible for what will be 3 Maintenance releases. Be very careful with your implementation. The current issue is that when removing the observers that hold references to a given mediator, each observer list is traversed and when a reference is found it the observer is removed from the list with Array.splice(). This causes all the observers from that point on to move back one in the array. Since we are in an iterator driven loop, the next time the iterator is advanced, it actually skips over the one its supposed to be examining, because it moved back by one during the last iteration. This will cause a release 1.7 of the AS3 reference implementation sometime within the next week. If you haven't seen it yet, have a look at this bug report: http://forums.puremvc.org/index.php?topic=145.0 I'll be implementing the fix described as 'Copy the survivors' in my response there. You might want to have a look at implementing this in your ports. -=Cliff> Title: Re: Remove Mediator Bug Post by: puremvc on December 09, 2007, 09:07:09 A more elegant solution presented itself:
http://forums.puremvc.org/index.php?topic=145.msg484#msg484 I'll be posting the code in the next day or two, but here's the method: /** -=Cliff>Title: Re: Remove Mediator Bug Post by: puremvc on January 14, 2009, 06:26:18 Please double check the latest AS3 reference and not the code above to be sure that you're porting the actual method, as it may have changed since this post. I'm not removing this thread because it is still an important method to make sure you have right!
-=Cliff> |