How to use @lumino/polling - 5 common examples

To help you get started, we’ve selected a few @lumino/polling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / packages / codemirror / src / editor.ts View on Github external
let model = (this._model = options.model);
    let config = options.config || {};
    let fullConfig = (this._config = {
      ...CodeMirrorEditor.defaultConfig,
      ...config
    });
    let editor = (this._editor = Private.createEditor(host, fullConfig));

    let doc = editor.getDoc();

    // Handle initial values for text, mimetype, and selections.
    doc.setValue(model.value.text);
    this.clearHistory();
    this._onMimeTypeChanged();
    this._onCursorActivity();
    this._poll = new Poll({
      factory: async () => {
        this._checkSync();
      },
      frequency: { interval: 3000, backoff: false },
      standby: () => {
        // If changed, only stand by when hidden, otherwise always stand by.
        return this._lastChange ? 'when-hidden' : true;
      }
    });

    // Connect to changes.
    model.value.changed.connect(this._onValueChanged, this);
    model.mimeTypeChanged.connect(this._onMimeTypeChanged, this);
    model.selections.changed.connect(this._onSelectionsChanged, this);

    CodeMirror.on(editor, 'keydown', (editor: CodeMirror.Editor, event) => {
github jupyterlab / jupyterlab / packages / services / src / kernelspec / manager.ts View on Github external
constructor(options: KernelSpecManager.IOptions = {}) {
    super(options);

    // Initialize internal data.
    this._ready = Promise.all([this.requestSpecs()])
      .then(_ => undefined)
      .catch(_ => undefined)
      .then(() => {
        if (this.isDisposed) {
          return;
        }
        this._isReady = true;
      });

    this._pollSpecs = new Poll({
      auto: false,
      factory: () => this.requestSpecs(),
      frequency: {
        interval: 61 * 1000,
        backoff: true,
        max: 300 * 1000
      },
      name: `@jupyterlab/services:KernelSpecManager#specs`,
      standby: options.standby ?? 'when-hidden'
    });
    void this.ready.then(() => {
      void this._pollSpecs.start();
    });
  }
github databrickslabs / jupyterlab-integration / extensions / databrickslabs_jupyterlab_statusbar / src / dbstatus.tsx View on Github external
// When a kernel gets strted, restarted or stopped, update the kernel id
          options.labShell.currentChanged.connect((_, change) => {
            const { oldValue, newValue } = change;
            if (oldValue) {
              var context = (oldValue as NotebookPanel).sessionContext
              context.connectionStatusChanged.disconnect(this.onConnectionStatusChange, this)
            }
            if (newValue) {
              var context = (newValue as NotebookPanel).sessionContext
              context.connectionStatusChanged.connect(this.onConnectionStatusChange, this)
            }
          })
        }
      )

      this._poll = new Poll({
        factory: () => Private.factory(this, options.notebookTracker),
        frequency: {
          interval: options.refreshRate,
          backoff: true
        },
        name: 'statusbar-extension:databrickslabs-jupyterlab#status'
      });

      this._poll.ticked.connect(poll => {
        const { payload, phase } = poll.state;

        if (phase === 'resolved') {
          this._updateStatusValues(payload);
          return;
        }
        if (phase === 'rejected') {
github jupyterlab / jupyterlab / packages / application / src / shell.ts View on Github external
(msg as Widget.ChildMessage).child.removeClass(ACTIVITY_CLASS);
        this._tracker.remove((msg as Widget.ChildMessage).child);
        break;
      default:
        break;
    }
    return true;
  };

  private _activeChanged = new Signal(this);
  private _cachedLayout: DockLayout.ILayoutConfig | null = null;
  private _currentChanged = new Signal(this);
  private _dockPanel: DockPanel;
  private _isRestored = false;
  private _layoutModified = new Signal(this);
  private _layoutDebouncer = new Debouncer(() => {
    this._layoutModified.emit(undefined);
  }, 0);
  private _leftHandler: Private.SideBarHandler;
  private _restored = new PromiseDelegate();
  private _rightHandler: Private.SideBarHandler;
  private _tracker = new FocusTracker();
  private _headerPanel: Panel;
  private _topHandler: Private.PanelHandler;
  private _bottomPanel: Panel;
  private _mainOptionsCache = new Map();
  private _sideOptionsCache = new Map();
}

namespace Private {
  /**
   * An object which holds a widget and its sort rank.
github jupyterlab / jupyterlab / packages / statusbar / src / defaults / memoryUsage.tsx View on Github external
constructor(options: Model.IOptions) {
      super();
      this._poll = new Poll({
        factory: () => Private.factory(),
        frequency: {
          interval: options.refreshRate,
          backoff: true
        },
        name: '@jupyterlab/statusbar:MemoryUsage#metrics'
      });
      this._poll.ticked.connect(poll => {
        const { payload, phase } = poll.state;
        if (phase === 'resolved') {
          this._updateMetricsValues(payload);
          return;
        }
        if (phase === 'rejected') {
          const oldMetricsAvailable = this._metricsAvailable;
          this._metricsAvailable = false;

@lumino/polling

Lumino Polling

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis

Popular @lumino/polling functions

Similar packages