当前位置: 首页>>代码示例>>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;未经允许,请勿转载。