Suppose I have a code that needs to be repeated several times. I need setInterval start on a command, that is, initially setInterval set, but it is not running, and only when a specific command is given from another part of the program, the repetitions start.

Closed due to the fact that the essence of the issue is incomprehensible to the participants by Grundy , aleksandr barakin , Streletz , Dmitriy Simushev , VenZell 20 May '16 at 16:13 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    call setInterval "when a certain command is given from another part of the program" - Igor
  • So I need to put the setInterval in observer ? MutationObserver(mutations => { mutations.forEach(mutation => { if(offerPanel.display != 'none'){ - SloGS
  • one
    I do not know about the "Suva", there is nothing in the question about the observer. setInterval is a function that starts a timer and returns an interval id. It is from this and proceed. - Igor

1 answer 1

 //место где будет вызываться function startInterval(){ setInterval( say, 500) } // функция которая будет исполняться function say() { console.log("таймер сработал") } // запуск для примера startInterval()