More events to generate based on the subscriber's list.
[smartthings-infrastructure.git] / Methods / runIn.groovy
1 /////////////////////////////////////////////////////////////////////
2 ////runIn(time, func)
3 def runIn(int seconds, Closure functionToCall) {
4         if (timersFuncList.contains(functionToCall)) {
5                 timersList[timersFuncList.indexOf(functionToCall)].cancel()
6                 def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
7         } else {
8                 timersFuncList.add(functionToCall)
9                 timersList.add(new SimulatedTimer())
10                 def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
11         }
12 }