The following code doesn't clear the interval and the callback gets executed infinitely:
mV = vm.progressViewModel.get("maxValue"); // 100
vm.progressViewModel.set("currentValue", 0);
// create a repeating timer to jump our progress value
t = timer.setInterval(function () {
var cV = vm.progressViewModel.get("currentValue");
var nV = cV + 5;
console.log("new: " + nV + ", max: " + mV);
if (nV >= mV) {
console.log(">=!!!");
timer.clearInterval(t);
} else {
vm.progressViewModel.set("currentValue", nV);
}
}, 500);
The following code doesn't clear the interval and the callback gets executed infinitely: