当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript jQuery.Deferred函数代码示例

本文整理汇总了TypeScript中jQuery.Deferred函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Deferred函数的具体用法?TypeScript Deferred怎么用?TypeScript Deferred使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Deferred函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

 return function () {
     var args = arguments;
     var closure = function () {
         return f.apply(undefined, args);
     };
     var d = $.Deferred();
     pendingf = function () {
         var exe = $.Deferred();
         var cd = closure();
         if (!cd || !$.isFunction(cd.always)) {
             throw "Return value of wrapped function must be a deferred";
         }
         cd = cd.always(function () { exe.resolve(); });
         pipeDeferred(cd, d);
         return exe;
     };
     running = running.then(function () {
         if (pendingf) {
             var temp = pendingf;
             pendingf = undefined;
             return temp();
         }
     });
     return d;
 };
开发者ID:hraban,项目名称:lush,代码行数:25,代码来源:utils.ts

示例2: function

  reject: function() {
    let deferred = $.Deferred().reject()
    let promise = deferred.promise()

    attachImmediatelyRejectingThen(promise)

    return promise
  }
开发者ID:caseyjhol,项目名称:fullcalendar,代码行数:8,代码来源:Promise.ts

示例3: setTimeout

    load_data: (frm: number, to: number) => {
        console.error(`frm[${frm}] to[${to}]`)

        let $deferred = $.Deferred<string[]>();

        if (to > MAX_SIZE - 1) {
            to = MAX_SIZE - 1;
        }

        setTimeout(() => {
            $deferred.resolve(_.range(frm, to + 1).map((e) => `remote ${e}`));
        }, 500);

        return $deferred.promise();
    }
开发者ID:llCorvinSll,项目名称:rxjs-sample,代码行数:15,代码来源:app.ts

示例4: getItem

 getItem(id: number) {
     var deferred = $.Deferred();
     $.ajax({
         type: "GET",
         url: `${this.url}/${id}`,
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success(data: T) {
             return deferred.resolve(data);
         },
         error(msg: any) {
             console.log("error calling service");
             console.log(msg);
             return deferred.reject(msg);
         }
     });
     return deferred;
 }
开发者ID:Equinox707,项目名称:smartAngular2017,代码行数:18,代码来源:voucher.service.ts

示例5: getVouchers

 getVouchers() {
     var deferred = $.Deferred();
     $.ajax({
         type: "GET",
         url: "/assets/vouchers.json",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success(data: Voucher[]) {
             return deferred.resolve(data);
         },
         error(msg: any) {
             console.log("error calling service");
             console.log(msg);
             return deferred.reject(msg);
         }
     });
     return deferred;
 }
开发者ID:Equinox707,项目名称:smartAngular2017,代码行数:18,代码来源:voucher.service.ts

示例6: get

  private static get() {
    return $.Deferred(function() {
      const deferred = this;

      const jqXHR = $.ajax({
        method: "GET",
        url: Routes.apiv1LatestVersionInfoPath(),
        timeout: mrequest.timeout,
        beforeSend: mrequest.xhrConfig.forVersion("v1"),
        contentType: false
      });

      const didFulfill = (data: LatestVersion) => {
        deferred.resolve(data.latest_version);
      };

      const didReject = () => {
        deferred.reject(null);
      };

      jqXHR.then(didFulfill, didReject);
    }).promise();
  }
开发者ID:Skarlso,项目名称:gocd,代码行数:23,代码来源:version_updater.ts


注:本文中的jQuery.Deferred函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。