Timer.set change interval time dinamic way

#1

Hi hello to everyone, i have a question with use of Timers, i will put a case of use :slight_smile:

let config = {
   intervalControl: 10000
} 


let myTimer =Timer.set(config.intervalControl, Timer.REPEAT, function() {
  .....
}, null);

let changeTimerInterval = function(newInterval){

  myTimer.set(newInterval,Timer.REPEAT,function(){
     ....
  })
 
 }

this only an example to demostrate what i want to obtain, reading in the doc i found that i can delete a timer with id , but how do i know the id of the timer?, the final question how is the best way to dinamiclly change the timer interval.

#2

In your example myTimer is the timer id which can by used by Timer.del

let changeTimerInterval = function(newInterval){
  Timer.del(myTimer);
  myTimer=Timer.set(newInterval,Timer.REPEAT,function(){
     ....
  })
 
 }
#3

Great so many thanks dude!