How to use the @jupyterlab/observables/src.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 yuvipanda / simplest-notebook / 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 yuvipanda / simplest-notebook / 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 yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should remove the first occurrence of a specific item from the list', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.removeValue(1);
        expect(toArray(value)).to.deep.equal([2, 3]);
      });
github yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should be emitted when the list changes state', () => {
        let called = false;
        const value = new ObservableList();
        value.changed.connect(() => {
          called = true;
        });
        value.insert(0, 1);
        expect(called).to.equal(true);
      });
github yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should accept no arguments', () => {
        const value = new ObservableList();
        expect(value instanceof ObservableList).to.equal(true);
      });
github yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should return the new length of the list', () => {
        const values = [1, 2, 3, 4, 5, 6];
        const value = new ObservableList({ values });
        expect(value.removeRange(1, 3)).to.equal(4);
      });
github yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should remove a range of items from the list', () => {
        const values = [1, 2, 3, 4, 5, 6];
        const value = new ObservableList({ values });
        value.removeRange(1, 3);
        expect(toArray(value)).to.deep.equal([1, 4, 5, 6]);
      });
github yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should trigger a changed signal', () => {
        let called = false;
        const values = [1, 2, 3, 4, 5, 6];
        const value = new ObservableList({ values });
        value.changed.connect((sender, args) => {
          expect(sender).to.equal(value);
          expect(args.type).to.equal('remove');
          expect(args.newIndex).to.equal(-1);
          expect(args.oldIndex).to.equal(1);
          expect(args.oldValues[0]).to.equal(2);
          expect(args.newValues.length).to.equal(0);
          called = true;
        });
        value.remove(1);
        expect(called).to.equal(true);
      });
    });
github yuvipanda / simplest-notebook / 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 yuvipanda / simplest-notebook / tests / test-observables / src / observablelist.spec.ts View on Github external
it('should move an item from one index to another', () => {
        const value = new ObservableList({ values: [1, 2, 3] });
        value.move(1, 2);
        expect(toArray(value)).to.deep.equal([1, 3, 2]);
        value.move(2, 0);
        expect(toArray(value)).to.deep.equal([2, 1, 3]);
      });