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: registerCommand at Controller class  (Read 8471 times)
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« on: March 03, 2009, 12:40:23 »

why do we have the "view.registerObserver(" in the registerCommand function?
what is suppose to do. i pass the code and i can't understand why is that.
please someone can explain me.

10x,
Nisim
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 04, 2009, 05:54:04 »

There are two things that respond to notifications in the PureMVC framework: Mediators and Commands. Mediators are long-lived, and registered with the view. Commands are instantiated only when needed and go away when they're done.

The way that Commands are invoked is that the Controller is actually the notified Observer and its executeCommand method is called with the note. In that method, we discover which Command to instantiate and do so, then pass the noification to its execute method.

-=Cliff>
Logged
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« Reply #2 on: March 04, 2009, 06:41:54 »

ok, it now more understandable.
so when i send a notification, the Command and the madiator will get execute in the same call, right?

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



View Profile WWW Email
« Reply #3 on: March 07, 2009, 08:10:18 »

Correct. For any given notification name, there can be one command and any number of mediators set to be notified.

-=Cliff>
Logged
Pages: [1]
Print