本文整理汇总了TypeScript中es6-promise.Promise.then方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Promise.then方法的具体用法?TypeScript Promise.then怎么用?TypeScript Promise.then使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类es6-promise.Promise
的用法示例。
在下文中一共展示了Promise.then方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should hide the map', function () {
return hiddenMapPromise.then($selectors => {
expect(elemIsHidden($selectors.$playerMap));
expect(normalize($selectors.$playerMap.text())).to.equal('');
return $selectors;
});
});
示例2: before
before(function () {
return clientPromise.then(client => {
const $ = client.$;
Client.updatePlayerInfo({
playerName: 'Alice'
}, $);
Client.updateRoster([
{
name: 'Carol',
state: 'Preparing'
},
{
name: 'Alice',
state: 'Preparing'
}, {
name: 'Bob',
state: 'Preparing'
}
], $);
return client;
});
});
示例3: res
user.then(u => {
entry.then(e => {
if (u["admin"] || e["userid"] === u["id"]) {
res(true);
}
else { res(false); }
}).catch(e => errors.push[e]);
}).catch(e => errors.push[e]);
示例4: executeQueries
executeQueries(queries: IMcQueryEntry[]): Promise<IMcResult> {
let base: Promise<void> = Promise.resolve();
let result1: IMcResult = { list: [] };
let cli = this.client;
for (let entry of queries) {
base = base.then(() => {
return McLib.executeQuery(cli, entry).then(function (resultEntry) {
result1.list.push(resultEntry);
});
}).catch(err => {
// console.error("Error found:" + err);
});
}
return base.then(() => result1);
}
示例5: after
after(() => {
return clientPromise.then(window => {
window.close();
return window;
}, error => {
throw error;
});
});