本文整理汇总了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);
});
}
示例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);
}
示例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();
});
}
示例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);