本文整理匯總了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); })
]);
});