Skip to content

Mamoo released as open source

by Topper on March 15th, 2009

I just put the Motionbox Advanced Model Observer Observer (Mamoo) up on Github. It’s a light-weight (13k), but fairly powerful framework for javascript built on top of Prototype and the Motionbox EventHandler.

It’s fairly well documented and has a full suite of specs written in ScrewUnit.

Mamoo let’s you stop thinking about the “glue code” you need on a client-side app – and start thinking like “when this happens, I want this to happen.” – Event driven architecture in JS.

Checkout the readme for a romp through most of the features.

To whet your appetite, here’s a really small, but useful app written with Mamoo.
[js]
Message = MBX.JsModel.create(“Message”);

MBX.MessageView = MBX.JsView.create({
model: Message,

onInstanceCreate: function (message) {
var li = this.buildLi(message);
$(“message_list”).insert(li);
},

buildLi: function (message) {
var li = new Element(“li”, { id: message.primaryKey() });
li.update(message.get(‘body’));
li.updatesOn(message, “body”);
return li;
}
});

// This will add the ui element
var message = Message.create({ body: “this is my body!” });

// and if you change body, the ui will automatically update as well
message.set(‘body’, “some other body”);

[/js]

Assuming you have an ol with the id of “message_list” in your html page, now everytime you create a message, it’ll get populated into the DOM.

I also put together a 15minute screencast that gives you a quick demo of a bunch of the features of Mamoo.

Nifty?