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