event-do.js revision 2a165bf36ff23d834e73c333ea237fabace7a74d
* Allows for the insertion of methods that are executed before or after * Cache of objects touched by the utility * Execute the supplied method before the specified function * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @return {string} handle for the subscription * Execute the supplied method after the specified function * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @return {string} handle for the subscription * Execute the supplied method after the specified function * @param when {string} before or after * @param fn {Function} the function to execute * @param obj the object hosting the method to displace * @param sFn {string} the name of the method to displace * @param c The execution context for fn * @return {string} handle for the subscription // create a map entry for the obj if it doesn't exist // create a map entry for the method if it doesn't exist // re-route the method to our wrapper * Detach a before or after subscription * @param sid {string} the subscription handle ////////////////////////////////////////////////////////////////////////// * Wrapper for a displaced method with aop enabled * @param obj The object to operate on * @param sFn The name of the method to displace * Register a aop subscriber * @param sid {string} the subscriber id * @param fn {Function} the function to execute * @param when {string} when to execute the function * Execute the wrapped method // for (i=0; i<this.before.length; ++i) { // Stop processing if an Error is returned // this.logger.debug("Error before " + this.methodName + // Check for altered arguments // this.logger.debug("Params altered before " + // this.methodName + ": " ret.msg); // execute after methods. // for (i=0; i<this.after.length; ++i) { // Stop processing if an Error is returned // this.logger.debug("Error after " + this.methodName + // Check for a new return value // this.logger.debug("Return altered after " + // this.methodName + ": " newRet.msg); ////////////////////////////////////////////////////////////////////////// * Return an Error object when you want to terminate the execution * of all subsequent method calls * Return an AlterArgs object when you want to change the arguments that * were passed into the function. An example would be a service that scrubs * out illegal characters prior to executing the core business logic. * Return an AlterReturn object when you want to change the result returned * from the core method to the caller ////////////////////////////////////////////////////////////////////////// // Y["Event"] && Y.Event.addListener(window, "unload", Y.Do._unload, Y.Do);