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