Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mateusduraes opened this issue Oct 6, 2017 · 6 comments
Assignees

Comments

@mateusduraes
Copy link

mateusduraes commented Oct 6, 2017

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.

@guillefd
Copy link

guillefd commented Oct 6, 2017

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

@jamesdaniels
Copy link
Member

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

@jamesdaniels
Copy link
Member

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

@yaozuwang
Copy link

Thanks James

@DennisSmolek
Copy link

DennisSmolek commented Oct 11, 2017

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....

@hvsharma63
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants