Search code examples
angularfirebaseangularfireangularfire2angularfire5

angularfire2 5.0.0-rc.2 does not return empty value any more


In angularfire 2 4.x.x, I was using angularfire object observable to show loading status before the data was fetched from firebase like below.

const ref: FirebaseObjectObservale = AngularFireDatabase.object('/path');

<loading *ngIf="!ref | async"></loading>

<div *ngIf="ref | async">
 {{ ref.$value ? ref.$value : 'Content does not exist' }}
</div>

However, in latest angularfire2 version 5, firebaseObjectObservable was changed to Observable, which does not return anything if the data does not exist in firebase, which causes the loading bar shows up infinitely.

If the new observable returns empty or null value I can still have a workaround by doing below:

AngularFireDatabase.object('/path').subscribe(data => {
  hideLoading();
  if (!data) {
    showErrorMsg();
  }
})

But it does not return anything now.

Any one has encountered the same issue and has any solutions?

Many thanks!


Solution

  • This problem was caused by a bug in version 5.0.0 rc2 which has been fixed on rc3.

    Details can be seen here https://github.com/angular/angularfire2/pull/1264