var self = this;
somelibrary.AsynchronousCall().then(
function(result)
{
self.status = JSON.stringify(result);
self.fire("OnSuccess");
},
function(result)
{
self.status = JSON.stringify(result);
self.fire("OnError");
});
The <font face="Courier New, Courier, mono">fire</font> method could be made safer with a check that the event exists, but the above is the simplest form. I would suggest adding this to the template files for plugins and behaviors. What do others think?