diff --git a/packages/notebook-extension/package.json b/packages/notebook-extension/package.json index f54347860..1407bd2db 100644 --- a/packages/notebook-extension/package.json +++ b/packages/notebook-extension/package.json @@ -44,6 +44,7 @@ "@jupyterlab/apputils": "^3.0.0", "@jupyterlab/docmanager": "^3.0.0", "@jupyterlab/notebook": "^3.0.0", + "@lumino/polling": "^1.3.3", "@lumino/widgets": "^1.14.0" }, "devDependencies": { diff --git a/packages/notebook-extension/src/index.ts b/packages/notebook-extension/src/index.ts index c50fcb873..72adc3c11 100644 --- a/packages/notebook-extension/src/index.ts +++ b/packages/notebook-extension/src/index.ts @@ -20,6 +20,8 @@ import { IClassicShell } from '@jupyterlab-classic/application'; +import { Poll } from '@lumino/polling'; + import { Widget } from '@lumino/widgets'; /** @@ -84,9 +86,16 @@ const checkpoints: JupyterFrontEndPlugin = { if (classicShell) { classicShell.currentChanged.connect(onChange); } - // TODO: replace by a Poll - onChange(); - setInterval(onChange, 2000); + + new Poll({ + auto: true, + factory: () => onChange(), + frequency: { + interval: 2000, + backoff: false + }, + standby: 'when-hidden' + }); } };