Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Endless loop in angularfire2 subscription

I am getting data and add data to the same node within an subscription. How can I avoid the endless loop?

this.af.database.list('objects/').subscribe(x=>{   / the subscription is only needed once
  this.af.database.list('objects/').push({newobject: ''};
};
like image 756
daniel Avatar asked Jul 10 '26 23:07

daniel


1 Answers

Shoot me if I'm wrong, or don't, but I believe you can use the first() method:

this.af.database.list('objects/').first().subscribe(x=>{ 
  this.af.database.list('objects/').push({newobject: ''};
};
like image 140
Poul Kruijt Avatar answered Jul 14 '26 10:07

Poul Kruijt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!