RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.

Home Page:https://rocketchat.github.io/Rocket.Chat.Apps-engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Is there a way to use setTimeout() or setInterval() in Rocket.Chat App?

murtaza98 opened this issue · comments

I tried using setInterval() and setTimeout() in an Rocket.Chat App, but it didn't work.

Most probably the issue is because timers module(a prebuilt node module) is not supported by Apps-Engine. If this is the issue, then is there a way to achieve similar functionality in an Rocket.Chat App, i.e trigger a function after a specific number of seconds?

There is not and it is by design. App accessors are only guaranteed for the lifetime of an event. Which using those timers would lift other code out of the lifecycle of an event and potentially cause other issues. That is what #89 was originally meant to fix, but priorities have shifted since then.