How to use the @lumino/messaging.MessageLoop.installMessageHook function in @lumino/messaging

To help you get started, we’ve selected a few @lumino/messaging 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 jtpio / ipylab / src / widgets / shell.ts View on Github external
private async _add(payload: any): Promise {
    const { serializedWidget, area, args, id } = payload;
    const model = await unpack_models(serializedWidget, this.widget_manager);
    const view = await this.widget_manager.create_view(model, {});
    const title = await unpack_models(model.get('title'), this.widget_manager);
    const pWidget = view.pWidget;

    pWidget.id = id ?? DOMUtils.createDomID();

    MessageLoop.installMessageHook(pWidget, (handler: any, msg: Message) => {
      switch (msg.type) {
        case 'close-request': {
          const widgets = this.get('_widgets').slice();
          ArrayExt.removeAllWhere(widgets, (w: any) => w.id === handler.id);
          this.set('_widgets', widgets);
          this.save_changes();
          break;
        }
      }
      return true;
    });

    const updateTitle = (): void => {
      pWidget.title.label = title.get('label');
      pWidget.title.iconClass = title.get('icon_class');
      pWidget.title.closable = title.get('closable');
github jupyterlab / jupyterlab / packages / application / src / shell.ts View on Github external
constructor() {
    super();
    this.addClass(APPLICATION_SHELL_CLASS);
    this.id = 'main';

    let headerPanel = (this._headerPanel = new Panel());
    let topHandler = (this._topHandler = new Private.PanelHandler());
    let bottomPanel = (this._bottomPanel = new BoxPanel());
    let hboxPanel = new BoxPanel();
    let dockPanel = (this._dockPanel = new DockPanelSvg({
      kind: 'dockPanelBar'
    }));
    MessageLoop.installMessageHook(dockPanel, this._dockChildHook);

    let hsplitPanel = new SplitPanel();
    let leftHandler = (this._leftHandler = new Private.SideBarHandler());
    let rightHandler = (this._rightHandler = new Private.SideBarHandler());
    let rootLayout = new BoxLayout();

    headerPanel.id = 'jp-header-panel';
    topHandler.panel.id = 'jp-top-panel';
    bottomPanel.id = 'jp-bottom-panel';
    hboxPanel.id = 'jp-main-content-panel';
    dockPanel.id = 'jp-main-dock-panel';
    hsplitPanel.id = 'jp-main-split-panel';

    leftHandler.sideBar.addClass(SIDEBAR_CLASS);
    leftHandler.sideBar.addClass('jp-mod-left');
    leftHandler.stackedPanel.id = 'jp-left-stack';