Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function register(obj) {
- var events = {};
- for (var prop in obj) {
- if (typeof obj[prop] == 'function') {
- obj[prop] = (function (x_oldFunc) {
- return function () {
- events.before && events.before.call(obj);
- x_oldFunc.apply(obj, arguments);
- events.after && events.after.call(obj);
- };
- })(obj[prop]);
- }
- }
- obj.on = function (eventName, func) {
- if (typeof func != 'function') {
- return;
- }
- events[eventName] = func;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment