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


TypeScript base.Promise.as方法代碼示例

本文整理匯總了TypeScript中vs/base/common/winjs.base.Promise.as方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript base.Promise.as方法的具體用法?TypeScript base.Promise.as怎麽用?TypeScript base.Promise.as使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/base/common/winjs.base.Promise的用法示例。


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

示例1: next

export function sequence<T>(promiseFactory: ITask<TPromise<T>>[]): TPromise<T[]> {
	var results: T[] = [];

	// Reverse since we start with last element using pop()
	promiseFactory = promiseFactory.reverse();

	function next(): Promise {
		if (promiseFactory.length) {
			return promiseFactory.pop()();
		}

		return null;
	}

	function thenHandler(result: any): Promise {
		if (result) {
			results.push(result);
		}

		var n = next();
		if (n) {
			return n.then(thenHandler);
		}

		return TPromise.as(results);
	}

	return Promise.as(null).then(thenHandler);
}
開發者ID:inspiredjw,項目名稱:VisualStudioCode,代碼行數:29,代碼來源:async.ts

示例2:

		return this.repo.fetch().then(null, (err) => {
			if (err.gitErrorCode === GitErrorCodes.NoRemoteRepositorySpecified) {
				return Promise.as(null);
			}

			return Promise.wrapError(err);
		}).then(() => this.status());
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:7,代碼來源:rawGitService.ts

示例3: commit

	public commit(message:string, amend?: boolean, stage?: boolean): TPromise<IRawStatus> {
		var promise: Promise = Promise.as(null);

		if (stage) {
			promise = this.repo.add(null);
		}

		return promise
			.then(() => this.repo.commit(message, stage, amend))
			.then(() => this.status());
	}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:11,代碼來源:rawGitService.ts

示例4: start

	public start(args: env.ICommandLineArguments): Promise {
		env.log('Received data from other instance', args);

		// Otherwise handle in windows manager
		if (!!args.pluginDevelopmentPath) {
			windows.manager.openPluginDevelopmentHostWindow({ cli: args });
		} else if (args.pathArguments.length === 0 && args.openNewWindow) {
			windows.manager.open({ cli: args, forceNewWindow: true, forceEmpty: true });
		} else if (args.pathArguments.length === 0) {
			windows.manager.focusLastActive(args);
		} else {
			windows.manager.open({ cli: args, forceNewWindow: !args.openInSameWindow });
		}

		return Promise.as(null);
	}
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:16,代碼來源:main.ts

示例5: timebomb

function timebomb(): Promise {
	if (!env.product.expiryDate || Date.now() <= env.product.expiryDate) {
		return Promise.as(null);
	}

	return new Promise((c, e) => {
		dialog.showMessageBox({
			type: 'warning',
			title: env.product.nameLong,
			message: nls.localize('expired', "Expired"),
			detail: nls.localize('expiredDetail', "This pre-release version of {0} has expired.\n\nPlease visit {1} to download the current release.", env.product.nameLong, env.product.expiryUrl),
			buttons: [nls.localize('quit', "Quit"), nls.localize('openWebSite', "Open Web Site")],
			noLink: true,
		}, (i) => {
			if (i === 1) {
				shell.openExternal(env.product.expiryUrl);
			}

			e('Product expired');
		});
	});
}
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:22,代碼來源:main.ts

示例6:

			callOnRemote: () => Promise.as(true)
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:1,代碼來源:remote.test.ts

示例7: getParent

	getParent(tree: ITree, element: any): Promise {
		return Promise.as(null);
	}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:3,代碼來源:quickOpenViewer.ts

示例8: getChildren

	getChildren(tree: ITree, element: any): Promise {
		const model = this.modelProvider.getModel();
		return Promise.as(model === element ? model.entries : []);
	}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:4,代碼來源:quickOpenViewer.ts

示例9:

		var factoryFactory = (n: number) => () => {
			return Promise.as(n);
		};
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:3,代碼來源:async.test.ts


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