本文整理汇总了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();
});
});
示例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());
});
示例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());
});
示例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]
};
})))
示例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]
};
})))
示例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); })
]);
});