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


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

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


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

示例1: test

	test('Delayer', function (done) {
		let count = 0;
		let factory = () => {
			return TPromise.as(++count);
		};

		let delayer = new Async.Delayer(0);
		let promises: Promise[] = [];

		assert(!delayer.isTriggered());

		promises.push(delayer.trigger(factory).then((result) => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
		assert(delayer.isTriggered());

		promises.push(delayer.trigger(factory).then((result) => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
		assert(delayer.isTriggered());

		promises.push(delayer.trigger(factory).then((result) => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
		assert(delayer.isTriggered());

		Promise.join(promises).done(() => {
			assert(!delayer.isTriggered());
			done();
		});
	});
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:25,代碼來源:async.test.ts

示例2: assert

		delayer.trigger(factory).then((result) => {
			assert.equal(result, 1);
			assert(!delayer.isTriggered());

			promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
			assert(delayer.isTriggered());

			promises.push(delayer.trigger(factory).then(null, () => { assert(true, 'yes, it was cancelled'); }));
			assert(delayer.isTriggered());

			delayer.cancel();

			Promise.join(promises).then(() => {

				promises = [];

				assert(!delayer.isTriggered());

				promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
				assert(delayer.isTriggered());

				promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
				assert(delayer.isTriggered());

				Promise.join(promises).then(() => {
					assert(!delayer.isTriggered());

					done();
				});

				assert(delayer.isTriggered());
			});

			assert(delayer.isTriggered());
		});
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:35,代碼來源:async.test.ts

示例3: done

		]).done(() => {
			Promise.join([
				throttler.queue(factory).then((result) => { assert.equal(result, 3); }),
				throttler.queue(factory).then((result) => { assert.equal(result, 4); }),
				throttler.queue(factory).then((result) => { assert.equal(result, 4); }),
				throttler.queue(factory).then((result) => { assert.equal(result, 4); }),
				throttler.queue(factory).then((result) => { assert.equal(result, 4); })
			]).done(() => done());
		});
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:9,代碼來源:async.test.ts

示例4:

				.then(HEAD => Promise.join([this.getRepositoryRoot(), this.repo.getRefs(), this.repo.getRemotes()]).then(r => {
					return {
						repositoryRoot: r[0],
						status: status,
						HEAD: HEAD,
						refs: r[1],
						remotes: r[2]
					};
				})))
開發者ID:amanyel,項目名稱:vscode,代碼行數:9,代碼來源:rawGitService.ts

示例5:

				.then(HEAD => Promise.join([this.getRepositoryRoot(), this.repo.getHeads(), this.repo.getTags(), this.repo.getRemotes()]).then(r => {
					return {
						repositoryRoot: r[0],
						status: status,
						HEAD: HEAD,
						heads: r[1],
						tags: r[2],
						remotes: r[3]
					};
				})))
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:10,代碼來源:rawGitService.ts

示例6: test

	test('Throttler - non async', function () {
		let count = 0;
		let factory = () => {
			return TPromise.as(++count);
		};

		let throttler = new Async.Throttler();

		return Promise.join([
			throttler.queue(factory).then((result) => { assert.equal(result, 1); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 3); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 4); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 5); })
		]);
	});
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:16,代碼來源:async.test.ts


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