本文整理匯總了TypeScript中@aurelia/kernel.PLATFORM.setTimeout方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript PLATFORM.setTimeout方法的具體用法?TypeScript PLATFORM.setTimeout怎麽用?TypeScript PLATFORM.setTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@aurelia/kernel.PLATFORM
的用法示例。
在下文中一共展示了PLATFORM.setTimeout方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('is still true when a request is still in progress', function(done) {
const firstResponse = emptyResponse(200);
const secondResponse = new Promise((resolve) => {
PLATFORM.setTimeout(() => { resolve(emptyResponse(200)); }, 200);
});
fetch.onCall(0).returns(firstResponse);
fetch.onCall(1).returns(secondResponse);
expect(client.isRequesting, 'Before start').to.equal(false);
const request1 = client.fetch('http://example.com/some/cool/path');
const request2 = client.fetch('http://example.com/some/cool/path');
expect(client.isRequesting, 'When started').to.equal(true);
request1.then(() => {
expect(client.isRequesting, 'When request 1 is completed').to.equal(true);
}).catch(() => { done('Unexpected catch'); });
PLATFORM.setTimeout(() => { expect(client.isRequesting, 'After 100ms').to.equal(true); }, 100);
request2.then(() => {
expect(client.isRequesting, 'When all requests are finished').to.equal(false);
}).then(() => {
expect(fetch).to.have.callCount(2);
done();
}).catch(() => { done('Unexpected catch'); });
});
示例2: Promise
const secondResponse = new Promise((resolve) => {
PLATFORM.setTimeout(() => { resolve(emptyResponse(200)); }, 200);
});