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: event order in StartupManager  (Read 6521 times)
marcink
Jr. Member
**
Posts: 13


View Profile Email
« 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?
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #1 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
Logged
marcink
Jr. Member
**
Posts: 13


View Profile Email
« Reply #2 on: March 02, 2009, 08:56:03 »

thanks philip, i'll try the 2 notifications solution...
Logged
Pages: [1]
Print