本文整理汇总了TypeScript中vs/base/common/winjs.base.Promise.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript base.Promise.cancel方法的具体用法?TypeScript base.Promise.cancel怎么用?TypeScript base.Promise.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/base/common/winjs.base.Promise
的用法示例。
在下文中一共展示了base.Promise.cancel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: cancel
public cancel(): void {
this.cancelTimeout();
if (this.completionPromise) {
this.completionPromise.cancel();
this.completionPromise = null;
}
}
示例2: test
test('Throttler - cancel in the middle should not cancel other promises', function (done) {
let count = 0;
let factory = () => {
return TPromise.timeout(0).then(() => {
return ++count;
});
};
let throttler = new Async.Throttler();
let p3: Promise;
Promise.join([
throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 2'); }),
p3 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 3'); }, () => { assert(true, 'yes, it was cancelled'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
]).done(() => done());
p3.cancel();
});
示例3: test
test('Throttler - cancel the first queued promise should not cancel other promises', function(done) {
var count = 0;
var factory = () => {
return Promise.timeout(0).then(() => {
return ++count;
});
};
var throttler = new Async.Throttler();
var p2: Promise;
Promise.join([
throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
p2 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 2'); }, () => { assert(true, 'yes, it was cancelled'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 3'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
]).done(() => done());
p2.cancel();
});
示例4: test
test('Throttler - cancel the first queued promise should not cancel other promises', function () {
let count = 0;
let factory = () => {
return TPromise.timeout(0).then(() => {
return ++count;
});
};
let throttler = new Async.Throttler();
let p2: Promise;
const p = Promise.join([
throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
p2 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 2'); }, () => { assert(true, 'yes, it was cancelled'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 3'); }),
throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
]);
p2.cancel();
return p;
});
示例6:
}, () => {
this.activePromise.cancel();
});