本文整理匯總了TypeScript中@jupyterlab/coreutils.Poll.refresh方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Poll.refresh方法的具體用法?TypeScript Poll.refresh怎麽用?TypeScript Poll.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@jupyterlab/coreutils.Poll
的用法示例。
在下文中一共展示了Poll.refresh方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should resolve after `ticked` emits in lock step', async () => {
poll = new Poll({
factory: () =>
Math.random() > 0.5 ? Promise.resolve() : Promise.reject(),
frequency: { interval: 0, backoff: false },
name: '@jupyterlab/test-coreutils:Poll#tick-2'
});
const ticker: IPoll.Phase[] = [];
const tocker: IPoll.Phase[] = [];
poll.ticked.connect(async (_, state) => {
ticker.push(state.phase);
expect(ticker.length).to.equal(tocker.length + 1);
});
const tock = async (poll: IPoll) => {
tocker.push(poll.state.phase);
expect(ticker.join(' ')).to.equal(tocker.join(' '));
poll.tick.then(tock).catch(() => undefined);
};
// Kick off the promise listener, but void its settlement to verify that
// the poll's internal sync of the promise and the signal is correct.
void poll.tick.then(tock);
await poll.stop();
await poll.start();
await poll.tick;
await poll.refresh();
await poll.tick;
await poll.refresh();
await poll.tick;
await poll.refresh();
await poll.tick;
await poll.stop();
await poll.start();
await poll.tick;
await sleep(100);
await poll.tick;
expect(ticker.join(' ')).to.equal(tocker.join(' '));
});