Infinite loop in angularfire2 subscription

I am getting data and appending data to the same node as part of a subscription. How can I avoid endless loop?

this.af.database.list('objects/').subscribe(x=>{   / the subscription is only needed once
  this.af.database.list('objects/').push({newobject: ''};
};

      

+3


source to share


1 answer


Kill me if I'm wrong or not, but I believe you can use the method first()

:



this.af.database.list('objects/').first().subscribe(x=>{ 
  this.af.database.list('objects/').push({newobject: ''};
};

      

+4


source







All Articles