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


TypeScript lifecycle.ILifecycleService類代碼示例

本文整理匯總了TypeScript中vs/platform/lifecycle/common/lifecycle.ILifecycleService的典型用法代碼示例。如果您正苦於以下問題:TypeScript ILifecycleService類的具體用法?TypeScript ILifecycleService怎麽用?TypeScript ILifecycleService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ILifecycleService類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _triggerAndDisposeAction

	private _triggerAndDisposeAction(instantitationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Thenable<void> {
		const actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
		actionInstance.label = descriptor.label || actionInstance.label;

		// don't run the action when not enabled
		if (!actionInstance.enabled) {
			actionInstance.dispose();

			return void 0;
		}

		const from = args && args.from || 'keybinding';

		// run action when workbench is created
		return lifecycleService.when(LifecyclePhase.Running).then(() => {
			try {
				return TPromise.as(actionInstance.run(undefined, { from })).then(() => {
					actionInstance.dispose();
				}, (err) => {
					actionInstance.dispose();
					return TPromise.wrapError(err);
				});
			} catch (err) {
				actionInstance.dispose();
				return TPromise.wrapError(err);
			}
		});
	}
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:28,代碼來源:actions.ts

示例2: triggerAndDisposeAction

	private triggerAndDisposeAction(instantiationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Promise<void> {

		// run action when workbench is created
		return lifecycleService.when(LifecyclePhase.Ready).then(() => {
			const actionInstance = instantiationService.createInstance(descriptor.syncDescriptor);
			try {
				actionInstance.label = descriptor.label || actionInstance.label;

				// don't run the action when not enabled
				if (!actionInstance.enabled) {
					actionInstance.dispose();

					return undefined;
				}

				const from = args && args.from || 'keybinding';

				return Promise.resolve(actionInstance.run(undefined, { from })).then(() => {
					actionInstance.dispose();
				}, err => {
					actionInstance.dispose();

					return Promise.reject(err);
				});
			} catch (err) {
				actionInstance.dispose();

				return Promise.reject(err);
			}
		});
	}
開發者ID:eamodio,項目名稱:vscode,代碼行數:31,代碼來源:actions.ts

示例3: lifecycleTelemetry

export function lifecycleTelemetry(telemetryService: ITelemetryService, lifecycleService: ILifecycleService): IDisposable {
	return lifecycleService.onShutdown(event => {
		/* __GDPR__
		   "shutdown" : {
			  "reason" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
		   }
		 */
		telemetryService.publicLog('shutdown', { reason: ShutdownReason[event] });
	});
}
開發者ID:kieferrm,項目名稱:vscode,代碼行數:10,代碼來源:telemetryUtils.ts

示例4: triggerAndDisposeAction

	private async triggerAndDisposeAction(instantiationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Promise<void> {

		// run action when workbench is created
		await lifecycleService.when(LifecyclePhase.Ready);

		const actionInstance = instantiationService.createInstance(descriptor.syncDescriptor);
		actionInstance.label = descriptor.label || actionInstance.label;

		// don't run the action when not enabled
		if (!actionInstance.enabled) {
			actionInstance.dispose();

			return;
		}

		// otherwise run and dispose
		try {
			const from = args && args.from || 'keybinding';
			await actionInstance.run(undefined, { from });
		} finally {
			actionInstance.dispose();
		}
	}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:23,代碼來源:actions.ts

示例5: lifecycleTelemetry

export function lifecycleTelemetry(telemetryService: ITelemetryService, lifecycleService: ILifecycleService): IDisposable {
	return lifecycleService.onShutdown(event => {
		telemetryService.publicLog('shutdown', { reason: ShutdownReason[event] });
	});
}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:5,代碼來源:telemetryUtils.ts


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