本文整理汇总了TypeScript中vs/base/common/winjs.base.TPromise.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript base.TPromise.cancel方法的具体用法?TypeScript base.TPromise.cancel怎么用?TypeScript base.TPromise.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/base/common/winjs.base.TPromise
的用法示例。
在下文中一共展示了base.TPromise.cancel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: localDispose
private localDispose(): void {
this.toLocalDispose = dispose(this.toLocalDispose);
if (this.quickFixRequestPromise) {
this.quickFixRequestPromise.cancel();
this.quickFixRequestPromise = null;
}
}
示例2: cancel
public cancel(): void {
if (this._hasValue || this._hasErr) {
return;
}
this._isCanceled = true;
if (this._actual) {
this._actual.cancel();
} else {
this._onCancel();
}
}
示例3: onCursorPositionChanged
private onCursorPositionChanged(): void {
if (this.triggerAutoSuggestPromise) {
this.triggerAutoSuggestPromise.cancel();
this.triggerAutoSuggestPromise = null;
}
this.cancelDialog();
if (!this.updateScheduler) {
this.updateScheduler = new RunOnceScheduler(() => {
const pos = this.editor.getPosition();
let marker = this.lastMarker;
if (marker && Range.containsPosition(marker, pos)) {
// still on the same marker
if (this.lightBulpPosition) {
this.setDecoration(pos);
}
return;
}
if (!this.editor.isFocused()) {
// remove lightbulb when editor lost focus
this.setDecoration(null);
return;
}
this.lastMarker = marker = this.findMarker(pos, false);
if (!marker) {
// remove lightbulp
this.setDecoration(null);
return;
}
const $tRequest = timer.start(timer.Topic.EDITOR, 'quickfix/lighbulp');
const computeFixesPromise = this.computeFixes(marker);
computeFixesPromise.done((fixes) => {
this.setDecoration(!arrays.isFalsyOrEmpty(fixes) ? pos : null);
this.triggerAutoSuggest(marker);
$tRequest.stop();
}, (error) => {
onUnexpectedError(error);
this.setDecoration(null);
$tRequest.stop();
});
}, 250);
this.toLocalDispose.push(this.updateScheduler);
}
this.updateScheduler.schedule();
}
示例4: test
test('TPromise execution order (sync)', function () {
const order = [];
let promise = new TPromise(resolve => {
order.push('in executor');
resolve(1234);
}, () => order.push('cancelled'));
order.push('afterCreate');
promise = promise
.then(null, err => null)
.then(() => order.push('finally'));
promise.cancel();
order.push('afterCancel');
return promise.then(() => assert.deepEqual(order, ['in executor', 'afterCreate', 'finally', 'afterCancel']));
});
示例5: computeFixes
private computeFixes(range: IMarker | IRange): TPromise<IQuickFix2[]> {
let model = this.editor.getModel();
if (!QuickFixRegistry.has(model)) {
return TPromise.as(null);
}
if (this.quickFixRequestPromise && range === this.quickFixRequestPromiseRange) {
return this.quickFixRequestPromise;
}
if (this.quickFixRequestPromise) {
this.quickFixRequestPromise.cancel();
this.quickFixRequestPromise = null;
}
this.quickFixRequestPromiseRange = range;
this.quickFixRequestPromise = getQuickFixes(model, range);
return this.quickFixRequestPromise;
}
示例6: 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: TPromise;
const p = TPromise.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;
});
示例7: computeFixes
private computeFixes(range: IMarker | EditorCommon.IRange): TPromise<IQuickFix2[]> {
let model = this.editor.getModel();
if (!QuickFixRegistry.has(model)) {
return TPromise.as(null);
}
if (this.quickFixRequestPromise && range === this.quickFixRequestPromiseRange) {
return this.quickFixRequestPromise;
}
if (this.quickFixRequestPromise) {
this.quickFixRequestPromise.cancel();
this.quickFixRequestPromise = null;
}
this.quickFixRequestPromiseRange = range;
let quickFixes: IQuickFix2[] = [];
let promises = QuickFixRegistry.all(model).map(support => {
return support.getQuickFixes(model.getAssociatedResource(), range).then(result => {
if (!Array.isArray(result)) {
return
}
for (let fix of result) {
quickFixes.push({
id: fix.id,
label: fix.label,
documentation: fix.documentation,
score: fix.score,
support
});
}
}, err => {
errors.onUnexpectedError(err);
});
});
this.quickFixRequestPromise = TPromise.join(promises).then(() => quickFixes);
return this.quickFixRequestPromise;
}
示例9:
onCancel = this.show(severity, { message, actions }, () => promise.cancel());
示例10: once
once(handle.onDidDispose)(() => promise.cancel());