當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript async.retry函數代碼示例

本文整理匯總了TypeScript中async.retry函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript retry函數的具體用法?TypeScript retry怎麽用?TypeScript retry使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了retry函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: mktmpdir

  export function mktmpdir(callback: (err: any, path: string) => void) {
    let tempFolderPath: string;
    async.retry(10, (cb: ErrorCallback) => {
      let folderName = "superpowers-temp-";
      for (let i = 0; i < 16; i++) folderName += getRandomTmpCharacter();
      tempFolderPath = `${tmpRoot}/${folderName}`;
      fs.mkdir(tempFolderPath, cb);
    }, (err) => {
      if (err != null) { callback(err, null); return; }

      const ipcId = getNextIpcId();
      ipcCallbacks[ipcId] = () => { callback(null, tempFolderPath); };
      electron.ipcRenderer.send("authorize-folder", secretKey, ipcId, window.location.origin, tempFolderPath);
    });
  }
開發者ID:MSylvia,項目名稱:superpowers-app,代碼行數:15,代碼來源:index.ts

示例2: createTempFolder

function createTempFolder(callback: (err: Error) => any) {
  let tmpRoot = nodeRequire("os").tmpdir();

  let characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  function randomChar() {
    return characters[Math.floor(Math.random() * characters.length)];
  }

  async.retry(10, (cb: ErrorCallback) => {
    let folderName = "sup-love2d-";
    for (let i = 0; i < 16; i++) folderName += randomChar();

    tempFolderPath = `${tmpRoot}/${folderName}`;
    fs.mkdir(tempFolderPath, cb);
  }, callback);
}
開發者ID:popcade,項目名稱:superpowers-love2d,代碼行數:16,代碼來源:index.ts

示例3: flushUpdates

 flushUpdates(done?: ()=>void) {
     async.retry(
         {times: 20, interval: 100},
         (cb) => {
             if (this.store === null) {
                 requestAnimationFrame(function() {
                     cb("store not ready");
                 });
                 return;
             }
             this.flushUpdatesWithStore(cb);
         },
         function (err) {
             if(done) done();
         });
 }
開發者ID:drewp,項目名稱:homepage,代碼行數:16,代碼來源:streamed-graph.ts

示例4: function

        Async.times(this.getChapterCount() + 1, function(i:number, next: any)
        {
            if (i > 0)
            {
                Async.retry({ times: 3, interval: 0 }, function (callback: AsyncResultCallback<any, any>)
                {
                    Logging.log("Getting chapter #"+ i);
                    self.getPageSourceCode(i, function ()
                    {
                        var chapter = self.findChapterInfos(i);

                        if (!chapter)
                        {
                            self._event.emit("warning", "Error while fetching chapter #" + i + "... Retrying.");
                            callback("Error while fetching chapter #" + i)
                        }
                        else
                            callback(null, chapter);
                    });
                }, function (err: any, chapter: Chapter)
                {
                    if (!err)
                        self.getChapters().push(chapter);

                    self._event.emit("chapReady", self.getChapterCount());
                    next(err);
                });
            }
            else
                next();
        }, completedCallback);
開發者ID:p0ody,項目名稱:ff2ebook-node,代碼行數:31,代碼來源:FicFFNET.ts


注:本文中的async.retry函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。