PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: marcink on February 28, 2009, 05:43:58



Title: event order in StartupManager
Post by: marcink on February 28, 2009, 05:43:58
hi,

i have an application with 1 proxy (it will be more when the application is finished). i use the StartupManager to load it.

now, when i listen for the notifications, the smLoadingComplete is the first one, and the one stating that the proxy is loaded is second.

shouldn't it be the other way?


Title: Re: event order in StartupManager
Post by: philipSe on March 02, 2009, 03:48:41
In your application startup, I assume the StartupResourceLoadedCommand is registered before your mediators are registered; this means that a notification will trigger the command before the mediators.

Note that processing is single-threaded, so when a notification is handled by the first interested party, that handling runs to completion before the next interested party gets to handle the original notification.

1. Proxy sends notification "data loaded"
now all interested parties are actioned in sequence

2. First the SM command StartupResourceLoadedCommand is triggered
which causes SM to send "loading complete" notification
and this is picked up and reported by your mediator(s)

3. Next your interested mediators are triggered and report the "data loaded" notification.

This is normal with PureMVC.  Since we don't typically worry much about the strict sequence in which we register commands and mediators, we can't make assumptions about the sequence in which notification handlers will be executed. You could choose to have 2 notifications, A and B; proxy sends A and this is picked up by mediators, proxy sends B and this triggers the StartupResourceLoaded Command.

----Philip


Title: Re: event order in StartupManager
Post by: marcink on March 02, 2009, 08:56:03
thanks philip, i'll try the 2 notifications solution...