Tracker.autorun(function({
var x = Session.get('x');
Meteor.call('server' ,x, function(err, res){
if(res){
Session.set('x', 5);
}
});
});
You should never get
and set
the same reactive variable in the same reactive context. Here’s what happens:
- Get
x
(this establishes a reactive dependency onx
). - Do some stuff
- Set
x
(this invalidates the dependency and re-runs from 1.)
Basically, you have written a reactive infinite loop.
4 Likes