How to separate initial data load from incremental children with Firebase?

后端 未结 4 1550
[愿得一人]
[愿得一人] 2020-11-30 03:09

I have an application where new children get added to Firebase every 5 seconds or so. I have thousands of children.

On application load, I\'d like to process the ini

4条回答
  •  情歌与酒
    2020-11-30 03:56

    Improved the answer from @jacobawenger to not use a global state variable

    var ref = new Firebase('https://.firebaseio.com');
    
    ref.once('value', function(snapshot) {
      // do something here with initial value
    
      ref.on('child_added', function(snapshot) {
        // do something here with added childs
      });
    
    });
    

提交回复
热议问题