2

How do you know when the Polymerfire firebase-document element is synced?

To be specific the firebase-document binds with an object via its data attribute. The value of this object goes from undefined --> { } --> {actual persisted data}.

How can you listen for firebase-document completing it's instal data fetch from the server. I am trying to check if there is data written at that location.

Marc M.
  • 3,631
  • 4
  • 32
  • 53

1 Answers1

1

There is an issue open for this on GitHub. It is an unfortunate side effect caused by the solution to some other problem the author was trying to solve.

For now, all you can do is check that the object is empty (something like Object.keys(obj).length === 0) and do nothing if so.

You can't store an empty object in firebase, so if the data you are given is {}, you usually know it hasn't loaded yet.

JJJ
  • 340
  • 1
  • 8
  • The only problem is, since the value initializes as an empty object, you don't know if the value is still loading or if it that path does not exist in the database. What about the zeroValue property, it looks promising, but it's not well documented. – Marc M. Jul 29 '16 at 18:06
  • Yes, this is a major issue. A few of us have been discussing it over on github for a while: https://github.com/firebase/polymerfire/issues/33. For now, all you can really do is check the keys length and treat "not found" the same as "not loaded". – JJJ Aug 03 '16 at 15:00