How to use the @jupyterlab/observables.ObservableList 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 / 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);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should add an item to the end of the list', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.push(4);
        expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
      });