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: Can Proxy send StateMachine.ACTION Notification?  (Read 6930 times)
mariusht
Full Member
***
Posts: 26


View Profile Email
« on: July 13, 2009, 01:22:53 »

Hi,

Can Proxy send StateMachine.ACTION notification that triggers the StateMachine to begin a transition between States? If yes, do you have any real world scenarios when this happens. I know from your presentation http://puremvc.tv/#P003/ that Command or Mediator can send StateMachine.ACTION Notification, but i am not sure about Proxy.

Mariush T.
http://mariusht.com/blog/


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



View Profile WWW Email
« Reply #1 on: July 13, 2009, 01:48:18 »

It's best if you don't. The State Machine is very much a construct of the application and you want your model to remain portable.

Always consider the possibility that you might have multiple apps using the same model. Perhaps you have an AIR desktop version of your web based Flex app. The two applications will execute different use cases against the same model. And likely the state machine for each app will be somewhat if not totally different.

So if the Model assumes knowledge of the state machine for the specific application its built for, it will be hard to reuse elsewhere without modification.

For this same reason Proxies should define their own constants for communicating updates to the app.

So if you find yourself wanting to broadcast a StateMachine.ACTION from a Proxy, instead consider having a command mapped to a Proxy's notification and in turn broadcast the desired StateMachine.ACTION. Or there's nothing saying you couldn't have a mediator be interested in that Proxy's note and have it do the rebroadcast as an ACTION, in the same way that Mediators often rebroadcast events from the view as Notifications.

-=Cliff>
Logged
mariusht
Full Member
***
Posts: 26


View Profile Email
« Reply #2 on: July 13, 2009, 09:56:32 »

I completely forgot about possibility of having multiple apps using the same model. Now i understand why NOT to send a StateMachine.ACTION from a Proxy.

Cliff, Great explanation, Thanks a lot!

Mariush T.
http://mariusht.com/blog/
Logged
Pages: [1]
Print