How to use @lumino/signaling - 10 common examples

To help you get started, we’ve selected a few @lumino/signaling 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 / tests / test-console / src / foreign.spec.ts View on Github external
contentFactory
    }).initializeState();
    return cell;
  }

  getCell(msgId: string) {
    return this._cells.get(msgId);
  }

  private _cells = new Map();
}

class TestHandler extends ForeignHandler {
  injected = new Signal(this);

  received = new Signal(this);

  rejected = new Signal(this);

  methods: string[] = [];

  protected onIOPubMessage(
    sender: IClientSession,
    msg: KernelMessage.IIOPubMessage
  ): boolean {
    const injected = super.onIOPubMessage(sender, msg);
    this.received.emit(msg);
    if (injected) {
      this.injected.emit(msg);
    } else {
      // If the message was not injected but otherwise would have been, emit
      // a rejected signal. This should only happen if `enabled` is `false`.
github jupyterlab / jupyterlab / packages / documentsearch / src / searchinstance.ts View on Github external
dispose() {
    if (this.isDisposed) {
      return;
    }
    this._isDisposed = true;

    // If a query hasn't been executed yet, no need to call endSearch
    if (this._displayState.query) {
      void this._activeProvider.endSearch();
    }

    this._searchWidget.dispose();
    this._disposed.emit(undefined);
    Signal.clearData(this);
  }
github jupyterlab / lumino / packages / widgets / src / focustracker.ts View on Github external
dispose(): void {
    // Do nothing if the tracker is already disposed.
    if (this._counter < 0) {
      return;
    }

    // Mark the tracker as disposed.
    this._counter = -1;

    // Clear the connections for the tracker.
    Signal.clearData(this);

    // Remove all event listeners.
    each(this._widgets, w => {
      w.node.removeEventListener('focus', this, true);
      w.node.removeEventListener('blur', this, true);
    });

    // Clear the internal data structures.
    this._activeWidget = null;
    this._currentWidget = null;
    this._nodes.clear();
    this._numbers.clear();
    this._widgets.length = 0;
  }
github jupyterlab / jupyterlab / packages / docmanager / src / manager.ts View on Github external
dispose(): void {
    if (this.isDisposed) {
      return;
    }
    this._isDisposed = true;

    // Clear any listeners for our signals.
    Signal.clearData(this);

    // Close all the widgets for our contexts and dispose the widget manager.
    this._contexts.forEach(context => {
      return this._widgetManager.closeWidgets(context);
    });
    this._widgetManager.dispose();

    // Clear the context list.
    this._contexts.length = 0;
  }
github jupyterlab / jupyterlab / testutils / src / index.ts View on Github external
signal.connect((sender: T, args: U) => {
    if (!options.find || options.find(sender, args)) {
      try {
        Signal.disconnectReceiver(object);
        if (options.test) {
          options.test(sender, args);
        }
      } catch (e) {
        done.reject(e);
      }
      done.resolve(options.value || undefined);
    }
  }, object);
  return done.promise;
github jupyterlab / jupyterlab / tests / test-logconsole / src / registry.spec.ts View on Github external
dispose() {
    Signal.disconnectAll(this);
  }
  args: ARGS[] = [];
github jupyterlab / jupyterlab / tests / test-logconsole / src / logger.spec.ts View on Github external
dispose() {
    Signal.disconnectAll(this);
  }
  args: ARGS[] = [];
github jupyterlab / jupyterlab / tests / test-logconsole / src / widget.spec.ts View on Github external
dispose() {
    Signal.disconnectAll(this);
  }
  args: ARGS[] = [];
github jupyterlab / jupyterlab / tests / test-services / src / session / isession.spec.ts View on Github external
defaultSession.kernelChanged.connect((s, args) => {
          called = args;
          Signal.disconnectReceiver(object);
        }, object);
        const previous = defaultSession.kernel;
github jupyterlab / jupyterlab / packages / application / src / router.ts View on Github external
const result = await commands.execute(command, current);
        if (result === stop) {
          queue.length = 0;
          console.log(`Routing ${request} was short-circuited by ${command}`);
        }
      } catch (reason) {
        console.warn(`Routing ${request} to ${command} failed`, reason);
      }
      void next();
    };
    void next();

    return done.promise;
  }

  private _routed = new Signal(this);
  private _rules = new Map();
}

/**
 * A namespace for `Router` class statics.
 */
export namespace Router {
  /**
   * The options for instantiating a JupyterLab URL router.
   */
  export interface IOptions {
    /**
     * The fully qualified base URL for the router.
     */
    base: string;

@lumino/signaling

Lumino Signals and Slots

BSD-3-Clause
Latest version published 5 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages