本文整理匯總了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());