Timers

Hi,

Say i am using 

timer.performWithDelay(1000, function() end, 1),

Is it necessary that i should assign this to an local variable and cancel after its use, i.e,

local timerVar = timer.performWithDelay(1000, function() end, 1)

timer.cancel(timerVar) 

timerVar = nil.

Thanks,

Kumar KS.

Well you have the timer set to only fire once after 1 second so unless you need to cancel that timer in that 1 second time frame then no you don’t need the variable. Although its always better to have one for just in case.

–SonicX278

Thanks for your reply.

If the timer is part of a function that gets called repeatedly, you won’t be able to cancel that timer without a handle if you need to.

Yes!

Hey @QuizMaster how’s the game coming along??

–SonicX278

Well you have the timer set to only fire once after 1 second so unless you need to cancel that timer in that 1 second time frame then no you don’t need the variable. Although its always better to have one for just in case.

–SonicX278

Thanks for your reply.

If the timer is part of a function that gets called repeatedly, you won’t be able to cancel that timer without a handle if you need to.

Yes!

Hey @QuizMaster how’s the game coming along??

–SonicX278