Assume I have an object with a member function that returns itself:
/* -- Object 1 -- */
function Object1(){
this.me = new Image(10,10);
this.me.src = "someImgUrl.jpg";
this.publish = function(){
return this.me;
}
}
In production:
var Obj1 = new Object1();
document.body.appendChild( Obj1.publish() );
Now, suppose I wanted to create an event that fires when the object's publish() method is called, but after the image is returned (something akin to an "onPublished()" event). Say, to to change the image dimensions to 100x100. How would I create it, and where would I "attach" it?
If I'm not being clear enough, please let me know. This is the simplest demo I could think of.