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