How to use the @jupyterlab/observables.ObservableMap function in @jupyterlab/observables

To help you get started, we’ve selected a few @jupyterlab/observables 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-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should not trigger a changed signal if not actually removed', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('three', 3);
        let called = false;

        value.changed.connect((sender, args) => {
          expect(sender).to.equal(value);
          expect(args.type).to.equal('remove');
          expect(args.key).to.equal('two');
          expect(args.oldValue).to.equal(2);
          expect(args.newValue).to.be.undefined;
          called = true;
        });

        // 'two' is not in the map
        value.delete('two');
        expect(called).to.equal(false);
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return `Map`', () => {
        const value = new ObservableMap();
        expect(value.type).to.equal('Map');
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return a list of the keys in the map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        value.set('three', 3);
        const keys = value.keys();
        expect(keys).to.deep.equal(['one', 'two', 'three']);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return the number of entries in the map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        expect(value.size).to.equal(2);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should test whether the map is disposed', () => {
        const value = new ObservableMap();
        expect(value.isDisposed).to.equal(false);
        value.dispose();
        expect(value.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return the old value for that key', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        const x = value.set('one', 1.01);
        expect(x).to.equal(1);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return undefined if the key does not exist', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        expect(value.get('two')).to.be.undefined;
      });
    });
github jupyterlab / debugger / src / handlers / notebook.ts View on Github external
constructor(options: NotebookHandler.IOptions) {
    this.debuggerService = options.debuggerService;
    this.notebookPanel = options.widget;
    this._cellMap = new ObservableMap();

    const notebook = this.notebookPanel.content;
    notebook.widgets.forEach(cell => this.addEditorHandler(cell));
    notebook.activeCellChanged.connect(this.onActiveCellChanged, this);
  }
github jupyterlab / jupyterlab / packages / notebook / src / celllist.ts View on Github external
constructor(modelDB: IModelDB, factory: NotebookModel.IContentFactory) {
    this._cellOrder = modelDB.createList('cellOrder');
    this._cellMap = new ObservableMap();

    this._cellOrder.changed.connect(this._onOrderChanged, this);
  }
github jtpio / ipylab / src / widgets / palette.ts View on Github external
static model_module = MODULE_NAME;
  static model_module_version = MODULE_VERSION;
  static view_name: string = null;
  static view_module: string = null;
  static view_module_version = MODULE_VERSION;

  private _palette: ICommandPalette;

  static palette: ICommandPalette;
}

/**
 * A namespace for private data
 */
namespace Private {
  export const customItems = new ObservableMap();
}