aurajs/aura — pull request #281 by sbellity (2013-06-30 01:23:55+00:00)
Title: Introducing AOP for Widgets (soon Components...)

Adding the ability to hook into the widgets lifecycle from extensions.

Example :

This is an extension that would call a `render` method automatically after `initialization` and then change all text colors to red :

**aura-extensions/make-it-red.js**

define(function(app) {

app.core.registerWidgetCallback("after:initialize", function() {
app.core.util.invokeWithCallbacks('render', this);
});

app.core.registerWidgetCallback("before:render", function() {
console.warn("About to render a Widget: ", this.options.name);
});

app.core.registerWidgetCallback("after:render", function() {
this.$el.css({ color: 'red' });
});

});