本文整理汇总了TypeScript中vs/base/common/async.Delayer.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Delayer.cancel方法的具体用法?TypeScript Delayer.cancel怎么用?TypeScript Delayer.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/base/common/async.Delayer
的用法示例。
在下文中一共展示了Delayer.cancel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: assert
const p = delayer.trigger(factory).then((result) => {
assert.equal(result, 1);
assert(!delayer.isTriggered());
promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
assert(delayer.isTriggered());
promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
assert(delayer.isTriggered());
delayer.cancel();
const p = Promise.all(promises).then(() => {
promises = [];
assert(!delayer.isTriggered());
promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
assert(delayer.isTriggered());
promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
assert(delayer.isTriggered());
const p = Promise.all(promises).then(() => {
assert(!delayer.isTriggered());
});
assert(delayer.isTriggered());
return p;
});
return p;
});
示例2: test
test('Delayer - cancel should cancel all calls to trigger', function () {
let count = 0;
let factory = () => {
return Promise.resolve(++count);
};
let delayer = new async.Delayer(0);
let promises: Thenable<any>[] = [];
assert(!delayer.isTriggered());
promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
assert(delayer.isTriggered());
promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
assert(delayer.isTriggered());
promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
assert(delayer.isTriggered());
delayer.cancel();
return Promise.all(promises).then(() => {
assert(!delayer.isTriggered());
});
});
示例3: request
protected request(channelName: string, name: string, arg: any): Promise {
if (!this.disposeDelayer) {
return Promise.wrapError('disposed');
}
this.disposeDelayer.cancel();
const channel = this.channels[channelName] || (this.channels[channelName] = this.client.getChannel(channelName));
const request: Promise = channel.call(name, arg);
// Progress doesn't propagate across 'then', we need to create a promise wrapper
const result = new Promise((c, e, p) => {
request.then(c, e, p).done(() => {
if (!this.activeRequests) {
return;
}
this.activeRequests.splice(this.activeRequests.indexOf(result), 1);
if (this.activeRequests.length === 0) {
this.disposeDelayer.trigger(() => this.disposeClient());
}
});
}, () => request.cancel());
this.activeRequests.push(result);
return result;
}
示例4:
this.child.on('exit', (code: any, signal: any) => {
process.removeListener('exit', onExit);
if (this.activeRequests) {
this.activeRequests.forEach(req => req.cancel());
this.activeRequests = [];
}
if (code && signal !== 'SIGTERM') {
console.warn('IPC "' + this.options.serverName + '" crashed with exit code ' + code);
this.disposeDelayer.cancel();
this.disposeClient();
}
});
示例5: dispose
dispose() {
this.disposeDelayer.cancel();
this.disposeDelayer = null;
this.disposeClient();
this.activeRequests = null;
}