Website address: http://dojotoolkit.org/reference-guide/1.10/dojo/aspect.html
After ()
Definition:after(target, methodName, advisingfunction, receivearguments);
Meaning: Executes the Advisingfunction method after the target's MethodName method.
function (aspect) { function(deferred) { // This was called after any dojo.xhr call }); // This would execute the original Dojo.xhr method and then our advising function DOJO.XHR ("GET", {...} );
Dojo.require ("Dojo.aspect"function(response) { ...});
Before ()
Definition:before(target, methodName, advisingfunction);
Meaning: Execute adviseingfunction before Target's MethodName method.
Define (["Dojo/aspect"],function(aspect) {Aspect.before (Dojo,"XHR",function(method, args) {//This is called before any dojo.xhr call if(method = = "PUT"){ //If the method is put, change it to a POST and PUT the method in the parameter stringArgs.url + = "? X-method=put"; //return the new args return["POST", args]; } }); //This would execute the original our advising function and then DOJO.XHRDOJO.XHR ("PUT", {...});});
Around ()
Definition: around (target Methodnameadvisingfactory);
function (aspect) { function(ORIGINALXHR) { returnfunction( method, args) { // doing something before the originalcall var deferred = Originalxhr (method, args); // doing something after the original call return deferred; } }); DOJO.XHR ("PUT", {...} );
Dojo official translation Dojo/aspect