How to use @jupyterlab/observables - 10 common examples

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 / observablelist.spec.ts View on Github external
it('should return the index occupied by the item', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        expect(value.removeValue(1)).to.equal(0);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should return the new length of the list', () => {
        const value = new ObservableList({ values: [1] });
        expect(value.pushAll([2, 3, 4])).to.equal(4);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should dispose of the resources held by the list', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.dispose();
        expect(value.isDisposed).to.equal(true);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should push an array of items to the end of the list', () => {
        const value = new ObservableList({ values: [1] });
        value.pushAll([2, 3, 4]);
        expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should remove all items from the list', () => {
        const values = [1, 2, 3, 4, 5, 6];
        const value = new ObservableList({ values });
        value.clear();
        expect(value.length).to.equal(0);
        value.clear();
        expect(value.length).to.equal(0);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should push an array of items into a list', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.insertAll(1, [2, 3, 4]);
        expect(toArray(value)).to.deep.equal([1, 2, 3, 4, 2, 3]);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should trigger a changed signal', () => {
        let called = false;
        const value = new ObservableList({ values: [1, 2, 3] });
        value.changed.connect((sender, args) => {
          expect(sender).to.equal(value);
          expect(args.type).to.equal('add');
          expect(args.newIndex).to.equal(3);
          expect(args.oldIndex).to.equal(-1);
          expect(toArray(args.newValues)).to.deep.equal([4, 5, 6]);
          expect(args.oldValues.length).to.equal(0);
          called = true;
        });
        value.pushAll([4, 5, 6]);
        expect(called).to.equal(true);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should insert an item into the list at a specific index', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.insert(1, 4);
        expect(toArray(value)).to.deep.equal([1, 4, 2, 3]);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should get the value at the specified index', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        expect(value.get(1)).to.equal(2);
      });
    });