i try show some text in function after this i want to wait 3 seconds and next i want run other functions. My pseudo code is:
showText();
wait 3 seconds
showSecondText();
showOtherText();
And now i wrote:
function helloOnClick(){
showText();
var myVar = setInterval(function(){showSecondText(data); showOtherText(data); clearInterval(myVar); },3000);
}
And now is almost perfect but when i click button and run helloOnClick() many times my functions showSecondText() will be run over and over becouse setInterval create many instance becouse clearInterval kills only one ?
How resolve this task ? I have two possibilities: 1. I can disabled button when function helloOnClick will be clicked and for end i can enabled 2. When click i can set flag on true and after finish change on false. When flag will be tru unction will not run.
What will be best choice ?