Friday, May 25th, 2007>p>Christos Constandinou has created Event.observeMethod, a library that gives you a way of adding event listeners to methods in an object and running other methods before, around and/ or after the method you are listening to.
The code itself is small, based on Prototype, and only 49 lines (1.8kb), uncompressed.
- Event.observeMethod( window, 'myNewFunc', myBeforeFunc, Event.BEFORE );
- Event.observeMethod( Friend, "initialize", this.addBirthday.bind( this ) );
Dojo has allowed you to do this kind of thing in its connect() model. You tend to wonder how often people need this granularity versus just being able to attach normal events.
It makes a lot of sense in large scale applications, but maybe not your JS hacking?
Posted by Dion Almaer at 8:15 am