I need to make some delays in my loop, every time after some amount of data (after a few cycles/iterations through my loop) is sent to the server.
Sending data and recei
You are continuously spawning multiple calls to process()
immediately in the while
and then telling process
to wait 5 seconds before that callback happens.
// Run this loop over and over again
while (true) {
// Create a function called process that process data
var process = (function () {
// Do something with data
console.log("Something");
// Wait a few seconds and do it again
setTimeout(process, 5000);
// This () right here says call process right now
}());
}