zoukankan      html  css  js  c++  java
  • dojo 官方翻译 dojo/aspect

    官网地址:http://dojotoolkit.org/reference-guide/1.10/dojo/aspect.html

    after()

    定义:after(target, methodName, advisingFunction, receiveArguments);

    意义:在target的methodName方法之后执行advisingFunction方法。

    define(["dojo/aspect"], function(aspect){
      aspect.after(dojo, "xhr", function(deferred){
        // this is called after any dojo.xhr call
      });
      // this will execute the original dojo.xhr method and then our advising function
      dojo.xhr("GET", {...});
    });
    dojo.require("dojo.aspect");
    dojo.aspect.after(dojo, "xhr", function(response){
      ...
    });

    before()

    定义:before(target, methodName, advisingFunction);

    意义:在target的methodName方法之前执行adviseingFunction。

    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 string
          args.url += "?x-method=PUT";
          // return the new args
          return ["POST", args];
        }
      });
      // this will execute the original our advising function and then dojo.xhr
      dojo.xhr("PUT", {...});
    });

    around()

    定义:around(target, methodName, advisingFactory);

    define(["dojo/aspect"], function(aspect){
      aspect.around(dojo, "xhr", function(originalXhr){
        return function(method, args){
          // doing something before the original call
          var deferred = originalXhr(method, args);
          // doing something after the original call
          return deferred;
        }
      });
      dojo.xhr("PUT", {...});
    });
  • 相关阅读:
    Hbase 笔记(4) 客户端API高级性能
    Hbase 笔记(3) 客户端API基础
    Hbase 笔记(2) 安装
    HBase 笔记(1) 简介
    Global 和 Local 索引。
    Phoenix Tips (14) mutable 和 immutable 表区别
    Phoenix Tips (13) 统计收集
    Phoenix Tips (12) 跟踪 Tracing
    Phoenix Tips (11) Skip Scan
    Phoenix Tips (10) 分页查询
  • 原文地址:https://www.cnblogs.com/tiandi/p/4492193.html
Copyright © 2011-2022 走看看