當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript base.TPromise.cancel方法代碼示例

本文整理匯總了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;
		}
	}
開發者ID:13572293130,項目名稱:vscode,代碼行數:7,代碼來源:quickFixModel.ts

示例2: cancel

	public cancel(): void {
		if (this._hasValue || this._hasErr) {
			return;
		}

		this._isCanceled = true;

		if (this._actual) {
			this._actual.cancel();
		} else {
			this._onCancel();
		}
	}
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:13,代碼來源:lazyPromise.ts

示例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();
	}
開發者ID:eklavyamirani,項目名稱:vscode,代碼行數:49,代碼來源:quickFixModel.ts

示例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']));
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:18,代碼來源:async.test.ts

示例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;
	}
開發者ID:13572293130,項目名稱:vscode,代碼行數:19,代碼來源:quickFixModel.ts

示例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;
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:22,代碼來源:async.test.ts

示例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;
	}
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:39,代碼來源:quickFixModel.ts

示例8:

		}, () => request.cancel());
開發者ID:liunian,項目名稱:vscode,代碼行數:1,代碼來源:ipc.cp.ts

示例9:

			onCancel = this.show(severity, { message, actions }, () => promise.cancel());
開發者ID:asotog,項目名稱:vscode,代碼行數:1,代碼來源:messageService.ts

示例10: once

			once(handle.onDidDispose)(() => promise.cancel());
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:1,代碼來源:notificationService.ts


注:本文中的vs/base/common/winjs.base.TPromise.cancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。