當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Poll.refresh方法代碼示例

本文整理匯總了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(' '));
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:37,代碼來源:poll.spec.ts


注:本文中的@jupyterlab/coreutils.Poll.refresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。