當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。