Skip to content

AngularFireDatabase doesn't execute functions when an empty list should be returned #1220

Closed

Description

@mateusduraes

Hello, seems like the AngularFireDatabase is not handling empty lists in the observables.

constructor(private afDb: AngularFireDatabase) {}
// ommited code
public userExists(email: string): Observable<boolean> {
  return this.afDb.list('/clients', ref =>
    ref.orderByChild('email').equalTo(email))
    .valueChanges()
    .map((users: User[]) => users.length > 0);
}

When i call the method with an email that exists in my realtime database, everything is fine, but if the observable should return an empty list, it is not triggered.

Activity

  1. guillefd commented on Oct 6, 2017

    @guillefd

    Same here, also snapshotChanges() doesn´t trigger when list is empty

  2. jamesdaniels commented on Oct 6, 2017

    @jamesdaniels
    Contributor

    K, I fixed in AFS I'll grab AFDB tonight + cut a new RC.

  3. self-assigned this
    on Oct 8, 2017
  4. jamesdaniels commented on Oct 10, 2017

    @jamesdaniels
    Contributor

    FYI this is a little trickier with RTDB + the new arch. Still in progress.

  5. yaozuwang commented on Oct 10, 2017

    @yaozuwang

    Thanks James

  6. DennisSmolek commented on Oct 11, 2017

    @DennisSmolek

    Heads up, getting this as well...
    core firebase.js says a snapshot should return null if empty but with the latest angularFire I dont get anything until a value exists.

    return this.af.list('/revisions/' + contentId + '/' + draftId).valueChanges(); and snapshotChanges() are both never firing their subscriptions..

    but:

    const ref = firebase.database().ref('/revisions/' + contentId + '/' + draftKey);
                        ref.once('value', snapshot => {
                            console.log('Firebase once returning:', snapshot.val());
    

    fires with Firebase once returning:null

    I had the listener setup with later functions init() binding inside the callback and my app just paused waiting for the callback....

  7. hvsharma63 commented on Sep 30, 2022

    @hvsharma63

    This issue still exists. When where queries are added in collection via reference & if the collection is empty, the subscription is not fired, on .valueChanges()
    image

  8. added a commit that references this issue on Mar 12, 2025
    eda1c41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions