How to use the @jupyterlab/observables/src.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 / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should trigger a changed signal', () => {
        let called = false;
        const value = new ObservableMap();
        value.changed.connect((sender, args) => {
          expect(sender).to.equal(value);
          expect(args.type).to.equal('add');
          expect(args.newValue).to.equal(1);
          expect(args.oldValue).to.be.undefined;
          expect(args.key).to.equal('one');
          called = true;
        });
        value.set('one', 1);
        expect(called).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should accept no arguments', () => {
        const value = new ObservableMap();
        expect(value instanceof ObservableMap).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should be emitted when the map changes state', () => {
        let called = false;
        const value = new ObservableMap();
        value.changed.connect(() => {
          called = true;
        });
        value.set('entry', 1);
        expect(called).to.equal(true);
      });
github jupyterlab / jupyterlab / 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 / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should dispose of the resources held by the map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        value.dispose();
        expect(value.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should remove all items from the map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        value.set('three', 3);
        value.clear();
        expect(value.size).to.equal(0);
        value.clear();
        expect(value.size).to.equal(0);
      });
github jupyterlab / jupyterlab / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should whether the key exists in a map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        expect(value.has('one')).to.equal(true);
        expect(value.has('two')).to.equal(false);
      });
    });
github jupyterlab / jupyterlab / 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 / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should return a list of the values in the map', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        value.set('three', 3);
        const keys = value.values();
        expect(keys).to.deep.equal([1, 2, 3]);
      });
    });
github jupyterlab / jupyterlab / tests / test-observables / src / observablemap.spec.ts View on Github external
it('should trigger a changed signal', () => {
        const value = new ObservableMap();
        value.set('one', 1);
        value.set('two', 2);
        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;
        });
        value.delete('two');
        expect(called).to.equal(true);
      });