Home » » Firebase run script after retrieving existing data

Firebase run script after retrieving existing data




I have a function in js that needs to refresh after I retrieve data from Firebase.
firebase.database().ref('/users/' + this.userId + '/info')
.on('child_added', function(snapshot){
    this.myFunction();
}.bind(this));
         The problem is that the data in Firebase is very large so I don't what to run the 
function lots of times.   
          This is how I what it to run:
  1. Retrieve ALL EXISTING data from Firebase.
  2. Run the function (once).
  3. Every time more data comes in from Firebase, run the function again.  

    I am guessing you want to retrieve all existing data from firebase at once
     then as more data comes in listen for those data changes. If that is your 
    case look at the method once() in firebase

0 nhận xét:

Post a Comment

Popular Posts

Powered by Blogger.