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: Some novice questions  (Read 6094 times)
chiekurs
Newbie
*
Posts: 3


View Profile Email
« on: September 09, 2007, 02:29:14 »

Hey ppl!

I just started to use pureMVC just few days ago so I'm pretty new to it hence i might be missing some basic things.
Anyhow, everything is great, everything is working except that I ran into some  issues I don't really understand.
First of all I noticed that if I do like this:
:
override public function handleNotification(notification:INotification):void {
trace("getName "+notification.getName())
}
I get traces from notifications current mediator isn't subscribed to.
Is that normal behavior or a bug? If thats normal behavior listNotificationInterests implementation lose any sense.
I would be grateful if anyone could explain me this issue.

Other thing give a lot more head ache.
I have a mediator which is needed only while user haven't logged on - LoginForm. I assumed that it would be only logical if i remove that mediator after user has logged on so I made class StartApplicationCommand which does
:
facade.removeMediator(LoginFormMediator.NAME);but this gives me error message
:
Error #1009: Cannot access a property or method of a null object reference.What is it all about?

Third issue is that before making separate START_APPLICATION notifier I wanted to use USER_LOGIN_SUCESSFULL which should inform  LoginForm that it's job is done and then invoke StartApplicationCommand, but as I noticed StartApplicationCommand.execute is fired before this message gets to LoginForm hence it didn't  knew when to remove it's visual component.
Is there any best practices on this issue or I should just use two notifiers and thats a normal way?
Btw, when i had implemented this layout i didn't get any error from removeMediator call.
That seems inconsistent to me.

Anyhow, can some explain to me what is it all about?
Btw I like pureMVC a lot it really make my life developing RIA's a lot more easy.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: September 09, 2007, 04:42:10 »

Hi,

As for your mediator being notified of notifications to which it is not subscribed, no this is not normal. Could you attach a small example app that is demonstrating this behavior?

The last section of your comment, I'm not able to follow completely. I'm not really sure what your desired chain of events / notifications is, what's listening to what, etc.

-=Cliff>
« Last Edit: September 16, 2007, 12:01:49 by puremvc » Logged
chiekurs
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: September 10, 2007, 12:13:31 »

Hello!

Thanks for reply!

I just figured that first issue wasn't really happening, my own mistake. So it's perfectly alright with notifying.

About third issue - the layout I've tried was like this:
1. LoginFormMediator receives user interaction and passes notification LOGIN_DATA_READY to everyone else.
2. UserLoginCommand is attached to that notification and fires sessionProxy.login with proper arguments.
3. When sessionProxy receives callback from server side it broadcast notification USER_LOGIN_SUCESSFULL
4.1 LoginFormMediator is subscribed to USER_LOGIN_SUCESSFULL
which commands it to remove visual component
4.2 StartApplicationCommand is also attached to that notification and tries to remove LoginFormMediator from mediator list

Hence, as I've noticed StartApplicationCommand is executed earlier than LoginFormMediator notification so  LoginFormMediator visual comoponent stays on stage.

I have a suspicion that it is normal behavior and what I did it the right thing.
I've changed event chain so StartApplicationCommand isn't attached to USER_LOGIN_SUCESSFULL and when LoginFormMediator  receives USER_LOGIN_SUCESSFULL after it's done removing of visual component it notifies others of START_APPLICATION notification.

Hope this time i'm more clear :)
« Last Edit: September 16, 2007, 12:02:47 by puremvc » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: September 16, 2007, 12:10:29 »

I removed a misleading statement (and response) from the thread made very late while muzzy. Facade.removeMediator is in fact there (there was a time when it was not).

Your error:

:
facade.removeMediator(LoginFormMediator.NAME);
but this gives me error message
:
Error #1009: Cannot access a property or method of a null object reference.

was most likely caused by the removeMediator issue that caused the 1.6 revision. See the Version 1.6 notes in the version.txt file in the current PureMVC distribution zip file.
Logged
Pages: [1]
Print