firebase-element icon indicating copy to clipboard operation
firebase-element copied to clipboard

Need an event to know when data has been fetched

Open Whyser opened this issue 10 years ago • 2 comments
trafficstars

It's really necessary to know when data has been retrieved.

At the moment the only solution is to attach an observer to the property that we binded to the data attribute and listen for changes. But this is troublesome since this property can change by other means then being retrieved from firebase.

Something like on-data-fetchedor similar, that gets called whenever new data is retrieved via a firebase-element (document or collection).

Whyser avatar Nov 07 '15 21:11 Whyser

Please refer to firebase events documentation here, to learn about events provided by the Firebase core library, and once you have learned them, i can tell you that Polymer.FirebaseQueryBehavior fires the following events:

  • firebase-child-added
  • firebase-child-removed
  • firebase-child-changed
  • firebase-child-moved

which you can use them by doing something like that

var fbEl = document.querySelector('firebase-collection');

fbEl.addEventListener('firebase-child-added', function(event){

})

abusada avatar Nov 10 '15 13:11 abusada

@ifaris7: In your list of events, you omitted firebase-value. But the problem is, all these events fire only after something "happens" to the firebase node or, in the case of firebase-value when a value is returned by the node query.

But we also need to know when the query returns null or undefined i.e., there is no firebase node at the end of the location property of the <firebase-collection> element.

maria-le avatar Nov 15 '15 08:11 maria-le