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: Notification firing multiple times in multicore version  (Read 5042 times)
notjones
Jr. Member
**
Posts: 10


View Profile Email
« on: May 09, 2008, 08:47:45 »

This issue is going to take some explanation.

First I have an application that uses dynamically loaded modules. To support this the main application mxml file contains a load module method that calls the currently loaded module and tells it it is going away, tells the main application's facade to remove core for the facade of the loaded module, sets the module loader's url to an empty string, finally sets the module loader's url to the new swf file. This appears to be working correctly and modules load as expected.

In the module where I'm having the problem, the your going away method does a remove core for the module's facade in an attempt to clear all of the facade related data.

With the above as background here's what is happening:

The loaded module (new doc panel) accepts data from the user then calls a proxy to post that data to a remote server. When the remote service call completes a notification is sent from the proxy. This works as expected.

User enters the module first time, files in the fields, and the new doc is sent to the server. Debug trace shows the proxy call is made and the completion notification received as expected.

The user then clicks in the menu to access the same module again. The app module load method follows the process described above and reloads the module. User enters new data for the second document and the proxy is called. Debug trace shows that the proxy is called once as expected, but the completion notification is received twice.

The user repeats the process, select the module from the menu, module loads again, user completes fields. Trace shows the proxy is called once as expected, but the completion notification is received three times.

Using debug and stepping through the code I can see that a new facade instance is being created for the module each time that it is being loaded. The question is where is the notification being stored so that it is firing multiple times? As it fires once for each time the module has been loaded I have no idea what is happening. Based on debug tracing I can only find the module in memory once. Is there something going on with PureMVC that is causing this?

Any ideas or help will be greatly appreciated.
Logged
trilec
Sr. Member
****
Posts: 52



View Profile WWW Email
« Reply #1 on: May 09, 2008, 09:00:52 »

have you tried running a small trace on the ApplicationFacade notifyObservers

Placed in your ApplicationFacade
This should report all notifications going on
:

...
import  org.puremvc.as3.multicore.interfaces.INotification; //will need this
...

override public function notifyObservers ( notification:INotification ):void {
if ( view != null ) {
view.notifyObservers( notification );
trace("notifyObservers: " + notification.getName());
}
}

T
Logged
notjones
Jr. Member
**
Posts: 10


View Profile Email
« Reply #2 on: May 09, 2008, 11:01:47 »

I did as suggested and displayed the notifications inside of the facade. I am seeing the notifications notifyObservers trace message fire once for each time that the module is loaded.

First time the module is loaded:
:
toolbarMediator toolbarAction: createactivity
notifyObservers: startup
notifyObservers: openfileupload
notifyObservers: uploadurireceived
notifyObservers: GetFileExtensions finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: GetActivityContactCandidates finished

2nd time the module is called:
:
toolbarMediator toolbarAction: createactivity
notifyObservers: uploadurireceived
notifyObservers: startup
notifyObservers: openfileupload
notifyObservers: GetActivityContactCandidates finished
notifyObservers: GetActivityContactCandidates finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: GetFileExtensions finished
notifyObservers: GetFileExtensions finished
notifyObservers: closefileupload

3rd time the module is loaded:
:
toolbarMediator toolbarAction: createactivity
notifyObservers: uploadurireceived
notifyObservers: startup
notifyObservers: openfileupload
notifyObservers: GetActivityContactCandidates finished
notifyObservers: GetActivityContactCandidates finished
notifyObservers: GetActivityContactCandidates finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: categoryavailable
notifyObservers: ListCategory finished
notifyObservers: GetFileExtensions finished
notifyObservers: GetFileExtensions finished
notifyObservers: GetFileExtensions finished

I was under the assumption that calling removeCore would clean up PureMVC, but that may not be happening.
Logged
notjones
Jr. Member
**
Posts: 10


View Profile Email
« Reply #3 on: May 09, 2008, 11:30:21 »

On the good news side, more tracing and debug indicates the sendNotification is being called multiple times in this situation. For each of the notifications triggered, there is a sendNotification occurring. So this does not appear to be a PureMVC issue, but instead something that is going on in Flex.

I'll just have to keep digging until I understand it.
Logged
Pages: [1]
Print