当前位置: 首页>>代码示例>>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;未经允许,请勿转载。