Monday 2 September 2013

Callback when 'class' instance is created

Callback when 'class' instance is created

var foo = (function(){
var c = function(requests) {
bar();
};
c.prototype = {
bar: bar
};
return c;
})();
var f = new foo();
f.baz(function(){
console.log('new instance of foo created');
});
http://jsfiddle.net/LecJM/
I would like to create a callback function which is called when a new
instance of the "class" foo is created. Is this possible? Obviously the
code above won't compile, I just want to give you an idea of what I'm
trying to achieve.

No comments:

Post a Comment