本文整理匯總了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);