question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FirebaseObjectObservable is deprecated but it still is used on this doc page https://github.com/angular/angularfire2/blob/master/docs/rtdb/objects.md

See original GitHub issue

it’s confuse, since the documentation in the link on the issue titles it still is use FirebaseObjectObservable instead of AngularFireList<T> as is mentioned on this link https://github.com/angular/angularfire2/blob/master/docs/version-5-upgrade.md

here an image what I’m getting when I try to use AngularFireList<T> to retrive an object image

please let me know how can I solve this issue?

thank you so much.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

16reactions
javieravilescommented, Dec 16, 2017

Let’s try to make some points here:

  • When working with the real-time database, version 5 is not using FirebaseListObservable and FirebaseObjectObservable anymore, instead, now it uses AngularFireList for lists and AngularFireObject for objects.
  • db.object(…) will give you back an AngularFireObject; db.list(…) and AngularFireList. So you could do AngularFireObject<any> author = db.object('authors').
  • if you add “.valueChanges()” afterwards, directly in the same statement, you are basically getting the Observable (whether it is a list or an object) of that AngularFireObject/List to which you can subscribe then. Observable<any> author = db.object('authors').valueChanges()
  • On the other hand, If you just get ‘authors’, it seems to me like you want to get a List, not an object, the whole list of authors, as you are not specifying any authorId to get just one… AngularFireObject<any> author = db.object('authors/${authorId}') or AngularFireList<any> authorsList = db.list('authors')
  • It is also a good practice if you previously define an interface or a class “Author” with correspondent attributes so you can do AngularFireObject<Author> instead of <any>
  • Another suggestion just so you know, your lines 1 and 3 could be merged together as import { Component, OnDestroy } from '@angular/core';

I hope this answer is readable and helpful for you:)

4reactions
javieravilescommented, Dec 21, 2017

Hi @kaygeeklaas,

Maybe in the “get started” section is not fully updated, but here you have the documentation in detail, all fine 😃

real time db docs updated

Anyway here is the solution to your problem: db.object will return an AngularFireObject indeed, but what you need to display on the view is an Observable<Author> (or Observable<any> in case you don’t want to define the object); to get an observable out of an AngularFireObject you need to call .valueChanges(), then your binding to the view for the authors list will work with the async pipe correctly.

component.ts

export class AppComponent {
    authors:Observable<any>

    constructor(db:AngularFireDatabase) {
        this.authors=db.object('/authors/1').valueChanges();
    }
}

component.html

{{ authors | async }}

I would encourage you to read a bit more of information about Observables in order to fully understand them

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the @angular/fire/database-deprecated ... - Snyk
To help you get started, we've selected a few @angular/fire/database-deprecated.FirebaseObjectObservable examples, based on popular ways it is used in ...
Read more >
error : AngularFireDatabase, @angular/fire/database ...
But I don't know how to use that to retrieve the app related data. That's why I'm using deprecated one FirebaseObjectObservable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found