PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: Tony on December 23, 2008, 03:38:53



Title: Shared model between Javascript <-> Flex ?
Post by: Tony on December 23, 2008, 03:38:53
Does pureMVC allow for a shared model between Javascript and Flex ?


Title: Re: Shared model between Javascript <-> Flex ?
Post by: puremvc on December 23, 2008, 04:35:00
I don't see why not. There is a PureMVC port for JS and for AS. Seems perfectly natural to pass data between the two. I imagine ActionScript VOs that have toJSON() methods and constructors that accept JSON objects. I also imagine middleware and utilities would be identified for marshalling the data back and forth. You might want to chat with Fredric our JavaScript port owner. (http://trac.puremvc.org/PureMVC/wiki/ProjectOwners/FredericSaunier)

Alternatively, there is also a Haxe port. Haxe will let you compile to JavaScript or ActionScript. Seems that would really be ultimate because you could output the AS and JS model from the same sources. have a look at http://haxe.org or chat with our Haxe port owner Marco (http://trac.puremvc.org/PureMVC/wiki/ProjectOwners/MarcoSecchi) for more on that approach.

Cheers,
-=Cliff>


Title: Re: Shared model between Javascript <-> Flex ?
Post by: Tekool on December 24, 2008, 04:29:03
I have worked on a proof of concept that uses an Actionscript PureMVC Proxy and a Javascript proxy. Each proxy uses both the same interface. Each one offer the same access to specific data, but one could use Javascript model or Flash model, the application didn't know anything about it. Each uses External Interface to access the real business object on the other side. This way the application do not have to communicate specific instances between Javascript and Flash because you share the same model. I simply create a new Proxy for each business object I need to share, one on each side.

In my proof of concept, the Javascript side did not have any user interface, but I think that if needed, you can use a Flash or Javascript mediator that mediate the other side view(s).

In my POC commands are unique for each side, but mediator from a side can modify the model to implicitely send a notification to the other side (strict MVC usage). It is probably not a good solution when you need to execute a consequent number of clearly determined commands from one side to the other. The better solution is, I suppose to use PureMVC multicore where Javascript is one ore more plug-in with a specific development to extend the PureMVC pipes utility to let it works with External Interface.