How to use the @angular/fire/database.listChanges function in @angular/fire

To help you get started, we’ve selected a few @angular/fire 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 angular / angularfire / src / database / list / changes.spec.ts View on Github external
it('should process a new child_changed event', (done) => {
      const aref = ref(rando());
      const obs = listChanges(aref, ['child_added','child_changed'])
      const sub = obs.pipe(skip(1),take(1)).subscribe(changes => {
        const data = changes.map(change => change.payload.val());
        expect(data[1].name).toEqual('lol');
      }).add(done);
      app.database().goOnline();
      aref.set(batch).then(() => {
        aref.child(items[1].key).update({ name: 'lol'});
      });
    });
github angular / angularfire / src / database / list / changes.spec.ts View on Github external
it('should stream events filtering', (done) => {
      const aref = ref(rando());
      const obs = listChanges(aref.orderByChild('name').equalTo('zero'), ['child_added']);
      obs.pipe(skip(1),take(1)).subscribe(changes => {
        const names = changes.map(change => change.payload.val().name);
        expect(names[0]).toEqual('zero');
        expect(names[1]).toEqual('zero');
      }).add(done);
      aref.set(batch);
      aref.push({ name: 'zero' });
    });
github angular / angularfire / src / database / list / changes.spec.ts View on Github external
it('should stream in order events', (done) => {
      const aref = ref(rando());
      const obs = listChanges(aref.orderByChild('name'), ['child_added']);
      const sub = obs.pipe(take(1)).subscribe(changes => {
        const names = changes.map(change => change.payload.val().name);
        expect(names[0]).toEqual('one');
        expect(names[1]).toEqual('two');
        expect(names[2]).toEqual('zero');
      }).add(done);
      aref.set(batch);
    });
github angular / angularfire / src / database / list / changes.spec.ts View on Github external
it('should stream value at first', (done) => {
      const someRef = ref(rando());
      const obs = listChanges(someRef, ['child_added']);
      const sub = obs.pipe(take(1)).subscribe(changes => {
        const data = changes.map(change => change.payload.val());
        expect(data).toEqual(items);
      }).add(done);
      someRef.set(batch);
    });