• Hi people.

    I have some troubles with the settimeout function.
    I have made a switch that an action can happen only one in the time of an interval.
    This cod is not specially meant for the espruino but i have tried this in the browser implemented in a website.
    The code works pretty well but if i click repeatedly fast, then the code ignores the if condition.
    Do i have made a mistake in this codeblock?

    var delay = true;
    function blogPostTimer(){
        if(delay == true){
            delay = false;
            postMessage();
        }else{
            setTimeout(function(){
            delay = true;
            }, 1000 * 5);
        }
    }
    
About