Functionality:
The secondary function is called when the initial condition is detected and satisfied. Therefore if '(condition = true)', the secondary function will be called. However, the secondary function should only be called once until the condition is changed to false.
Hence, the correct behaviour is that: The secondary function shouldn't be kept calling when the initial condition is still 'true', the correct behaviour is that it should only be called once when the 'condition =true' and when 'condition=false', nothing happens and the next instance when 'condition=true' again, the secondary function will be called again once, untill the condition = false.
At this point in time, what I have done is that at every 'condition= true', it will be always be calling the secondary function=>location.reload();
, which happpens to be the wrong behaviour. Therefore, if the 'condition=true' were to be true for 10 seconds, it will be refreshing every second for the 10 seconds.
Hence, at this point, I am stuck at how to only call 'location.reload()' only once when 'condition= true', such that it will only refresh the page once.
Therefore, I need help/guidance on how to only detect once and call function once when 'condition=true'
var isInterrupt =false;
//Interval to keep asking the backend for sensor value: Hence, if sensor value returns a '1', it will call the function interrupt()
setInterval(getFeedback,100);
function getFeedback()
{
ajax_getArduinoFeedback("flash.do", "formType=getArduinoFeedback");
}
//Method call when data from Arduino is "1"
function interrupt(){
//location.reload();
if (isInterrupt == false)
{
isInterrupt = true;
//When data="1" at the arduino board, Video will reload and start playing
location.reload();
}
isInterrupt=false;
}