本文整理匯總了TypeScript中Q.delay函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript delay函數的具體用法?TypeScript delay怎麽用?TypeScript delay使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了delay函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getFavs
return getFavs(200, max_id).then((new_max_id) => {
console.log('new max id is: ' + new_max_id);
return Q.delay(5000).then(() => {
console.log('new call');
return getFavsWithRetries(favs_left - 200, new_max_id - 1);
})
})
示例2: spawnReactPackager
/**
* Spawns the React Native packager in a child process.
*/
public spawnReactPackager(args?: string[], options: Options = {}): Q.Promise<ChildProcess> {
let deferred = Q.defer<ChildProcess>();
let command = this.getReactCommandName();
let runArguments = ["start"];
if (args) {
runArguments = runArguments.concat(args);
}
let spawnOptions = Object.assign({}, { cwd: this.currentWorkingDirectory }, options);
let result = new Node.ChildProcess().spawn(command, runArguments, spawnOptions);
result.spawnedProcess.once("error", (error: any) => {
deferred.reject(ErrorHelper.getNestedError(error, InternalErrorCode.PackagerStartFailed));
});
result.stderr.on("data", (data: Buffer) => {
Log.logMessage(data.toString(), /*formatMessage*/false);
});
result.stdout.on("data", (data: Buffer) => {
Log.logMessage(data.toString(), /*formatMessage*/false);
});
// TODO #83 - PROMISE: We need to consume result.outcome here
Q.delay(300).done(() => deferred.resolve(result.spawnedProcess));
return deferred.promise;
}
示例3: before
before(function() {
return Q.delay(500).then(function() {
return createTransactionPendingApproval();
})
.then(function(result) {
pendingApproval = result;
});
});
示例4:
.then(function(result) {
result.should.have.property('tx');
result.should.have.property('hash');
result.should.have.property('fee');
return Q.delay(3500)
.then(function() {
return testWallet.get();
});
})
示例5: require
jobs.define('failBoat2', (job, cb) => {
var Q = require('q');
Q.delay(100)
.then(() => {
throw(new Error("Zomg fail"));
})
.fail(cb)
.done();
});
示例6: Q
return Q(result).then(condition).then((conditionResult => {
if (conditionResult) {
return result;
}
if (iteration < maxRetries) {
return Q.delay(delay).then(() => this.retryAsyncIteration(operation, condition, maxRetries, iteration + 1, delay, failure));
}
throw new Error(failure);
}));
示例7: function
return CordovaIosDeviceLauncher.mountDeveloperImage().then(function (): Q.Promise<child_process.ChildProcess> {
let deferred = Q.defer<child_process.ChildProcess>();
CordovaIosDeviceLauncher.nativeDebuggerProxyInstance = child_process.spawn('idevicedebugserverproxy', [proxyPort.toString()]);
CordovaIosDeviceLauncher.nativeDebuggerProxyInstance.on('error', function (err: any): void {
deferred.reject(err);
});
// Allow 200ms for the spawn to error out, ~125ms isn't uncommon for some failures
Q.delay(200).then(() => deferred.resolve(CordovaIosDeviceLauncher.nativeDebuggerProxyInstance));
return deferred.promise;
});
示例8: function
return IosAppRunnerHelper.mountDeveloperImage().then(function(): Q.Promise<child_process.ChildProcess> {
const deferred = Q.defer<child_process.ChildProcess>();
SharedState.nativeDebuggerProxyInstance = child_process.spawn("idevicedebugserverproxy", [proxyPort.toString()]);
SharedState.nativeDebuggerProxyInstance.once("error", function(err: any): void {
deferred.reject(err);
});
// Allow 200ms for the spawn to error out, ~125ms isn't uncommon for some failures
Q.delay(200).then(() => deferred.resolve(SharedState.nativeDebuggerProxyInstance));
return deferred.promise;
});
示例9:
return this.mountDeveloperImage().then(function(): Q.Promise<void> {
const {spawnedProcess} = new Node.ChildProcess().spawnWithExitHandler("idevicedebugserverproxy", [proxyPort.toString()]);
this.nativeDebuggerProxyInstance = spawnedProcess;
const deferred = Q.defer<ChildProcess>();
spawnedProcess.on("error", (err: Error) => {
deferred.reject(err);
});
// Allow 200ms for the spawn to error out
return Q.delay(200);
});
示例10: startWebkitDebugProxy
public static startWebkitDebugProxy(proxyPort: number, proxyRangeStart: number, proxyRangeEnd: number): Q.Promise<any> {
if (CordovaIosDeviceLauncher.webDebuggerProxyInstance) {
CordovaIosDeviceLauncher.webDebuggerProxyInstance.kill();
CordovaIosDeviceLauncher.webDebuggerProxyInstance = null;
}
let deferred = Q.defer();
let portRange = `null:${proxyPort},:${proxyRangeStart}-${proxyRangeEnd}`;
CordovaIosDeviceLauncher.webDebuggerProxyInstance = child_process.spawn('ios_webkit_debug_proxy', ['-c', portRange]);
CordovaIosDeviceLauncher.webDebuggerProxyInstance.on('error', function (err: Error) {
deferred.reject(new Error('Unable to start ios_webkit_debug_proxy.'));
});
// Allow some time for the spawned process to error out
Q.delay(250).then(() => deferred.resolve({}));
return deferred.promise;
}