Thursday, January 8, 2009

Joosifying PureMVC

Based on Nickolay's work for Ext I implemented a Joose to PureMVC bridge. PureMVC is a MVC framework that was originally implemented for Flash/ActionScript3 but which has implementations for JavaScript, Java, C# and other languages.

Using the new Joose bridge you can use Joose to build PureMVC applications. You can use Joose's facilities to inherit from the PureMVC base classes and apply Joose-roles to all instances and classes included in PureMVC. The code works on the sample application. There seems to be no test suite in the main repository, so it cant be fully verified.

The bridge code is actually very simple. PureMVC uses a simple JavaScript class framework called objs.js. This framework provides a method called "register" to register classes and a method called "extend" to inherit from a super class. The bridge code overrides these methods. Thus automatically all classes from PureMVC can be turned into Joose classes without any further changes to the actual code of the framework.

You can download the code from the Joose repository. Just replace the file objs.js from the PureMVC download with the file from Joose and you are good to go.
The code was only minimally tested but seems to work. If there is further interest or as soon as I have a work project that uses the framework I'll invest further time in it.

2 comments:

Cliff said...

Hey, this is a pretty cool thing you've got going here with the drop in replacement for obs.js, which was written by the JS port author.

Clearly, having gone to this level of effort, you've got some interest in using PureMVC or seeing it used with Joose.

I'm really keen to see what you come up with, and what your thoughts about the working port are.

-=Cliff>

Malte said...

Hey Cliff,

I added some example code to the post on the PureMVC forums.

I think that objs is a really high entry barrier for non-super-guru JS authors because of all the stuff that you have to take care of only to be able to inherit from a Mediator, etc. With Joose this becomes trivial.