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]
Author Topic: Shared model between Javascript <-> Flex ?  (Read 3569 times)
Posts: 1

View Profile Email
« on: December 23, 2008, 03:38:53 »

Does pureMVC allow for a shared model between Javascript and Flex ?
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 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.

Sr. Member
Posts: 192

View Profile WWW Email
« Reply #2 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.
« Last Edit: December 24, 2008, 04:30:50 by Tek » Logged
Pages: [1]