Page 1 of 1

Problem with setTimeout and setInterval

Posted: 12 Jul 2014 00:37
by enco.josh
I have been using setInterval and setTimeout with no problems until today. I tried adding another setTimeout to my main.js file and it just would not run.

Code: Select all

var console = {
    log: debugPrint,
    warn: debugPrint,
    error: debugPrint,
    debug: debugPrint,
    logJS: function() {
        var arr = [];
        for (var key in arguments)
            arr.push(JSON.stringify(arguments[key]));
        debugPrint(arr);
    }
};

setTimeout(function() { 
	console.log("timeout 1");
}, 1000); 

setTimeout(function() { 
	console.log("timeout 2");
}, 1000); 
My only console output is timeout 2. Am I doing something wrong? Is there a workaround?

Re: Problem with setTimeout and setInterval

Posted: 13 Jul 2014 20:34
by PoltoS
Which version of Z-Way do you use? Does things change if you make delays different?

Re: Problem with setTimeout and setInterval

Posted: 14 Jul 2014 15:36
by enco.josh
Z-Way 1.7.1

Yes, if I change either timeout to 2000 ms (not both), they both execute.

Re: Problem with setTimeout and setInterval

Posted: 14 Jul 2014 17:29
by enco.josh
However, this code doesn't work. Only the timeout executes. Similarly, if I call setTimeout prior to setInterval, only the interval executes. It doesn't matter if the intervals are the same or not. Only the second one executes. I do have

Code: Select all

setInterval(function() {
	console.log("interval");
}, 1000);

setTimeout(function() {
	console.log("timeout");
}, 2000);