Call function every second

How can I call a function every second?
I would need to make a call HttpRequest, and the information must be updated, so I need a way to summon a function every second.

How can I do?

Thank you.

How can I call a function every second?
I would need to make a call HttpRequest, and the information must be updated, so I need a way to summon a function every second.

How can I do?

Thank you.

local function yourFunction()
  --do your thang
end
 

Runtime:addEventListener(“enterFrame”,yourFunction)

http://docs.coronalabs.com/daily/api/library/timer/performWithDelay.html

enterFrame would happen much more often than once a second.

lmao so true, I just realized what i wrote and yeah 30 to 60 times faster

Do you mean like this?

timer.performWithDelay(1000, function, 0)  

Every second function is called in an infinite loop, right?

1 Like

Yes.

How can I call a function every second?
I would need to make a call HttpRequest, and the information must be updated, so I need a way to summon a function every second.

How can I do?

Thank you.

local function yourFunction()
  --do your thang
end
 

Runtime:addEventListener(“enterFrame”,yourFunction)

http://docs.coronalabs.com/daily/api/library/timer/performWithDelay.html

enterFrame would happen much more often than once a second.

lmao so true, I just realized what i wrote and yeah 30 to 60 times faster

Do you mean like this?

timer.performWithDelay(1000, function, 0)  

Every second function is called in an infinite loop, right?

Yes.