Running periodic events on the agent

Is it possible to write a function that executes periodically, similar to the setInterval construct in JavaScript?

Yes, just like on the imp use imp.wakeup().

cool thanks