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

Pages: [1]
Print
Author Topic: Application Startup Notification Confusion  (Read 6490 times)
rosscoco
Newbie
*
Posts: 1


View Profile Email
« on: June 05, 2008, 04:17:50 »

Not so much a problem, but rather am confused as to WHY something is working when I expected it not too  :o

I have a Startup MacroCommand that executes InitView then InitModel commands, and in the InitView SimpleCommand I instantiate an ApplicationMediator that has among its Notification interests  the very same ApplicationStartup notification that executed the StartupCommand. 

My confusion is what kind of causal loop time paradox ( or similar ) allows the ApplicationMediator to respond to a notification that was sent BEFORE it was instantiated or registered with the facade, because that's what seems to be happening?   

If, in a Notification 'lifecycle', an object is instantiated/registered, does some bit of magic occur that checks if this Notification is listed in the new objects interests?  If so, well....very clever :) 






Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: June 05, 2008, 06:23:36 »

You've discovered the Flux Capacitor! It causes wierd time dialation effects and runs on Fritos and beer cans!

What's actually happening is that in View.notifyObserver, we're looping through the list of observers for the Notification, and before finishing that loop, we've added another observer to the list. Since the loop expression evaluates the array length each time, the list is able to expand while its being evaluated.

-=Cliff>
Logged
Pages: [1]
Print