PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: mariusht on July 13, 2009, 01:22:53



Title: Can Proxy send StateMachine.ACTION Notification?
Post by: mariusht 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/ (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/




Title: Re: Can Proxy send StateMachine.ACTION Notification?
Post by: puremvc 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>


Title: Re: Can Proxy send StateMachine.ACTION Notification?
Post by: mariusht 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/