Answer the question
In order to leave comments, you need to log in
How to make a synchronous loop in meteor?
How to make a synchronous loop in meteor? There are get requests in the loop, but they do not have time to be executed, as the loop is already scrolling. How to stop the loop until the get request is completed?
Answer the question
In order to leave comments, you need to log in
For example, instead of get we will use process.nextTick, which is the same with the callback, just replace it.
var util = require('util');
var j = 0;
function loop() {
if (++j < 100) {
console.log(j);
process.nextTick(loop);
}
}
process.nextTick(loop);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question