I have several javaScript classes (ctor + prototype methods) that I want their instances to generate evnets.
so that code using this class can look something like this:
var instance=new SomeObject(); instance.on('customEventName',function(event){do_stuff()}
I work in a jQuery environment and for the user interface elements that I use .trigger and .on, which works fine for me, I wandered what would be the best way to implement the same thing with respect to regular objects.
I am thinking of setting up a map of $ .Callbacks () objects based on the name of the custom event and adding .on and .trigger to the prototype object. Or maybe I can just save the eventPoint instance variable initialized to empty $ () and hook the .on and .trigger methods from the prototype to this eventPoint object.
Any other / best ideas?
epeleg
source share