Constructor
new TimerMgr(keyopt, cacheObjopt)
Constructor
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string |
<optional> |
key for the backing map in the cache |
cacheObj |
object |
<optional> |
cache object to use (defaults to cache.private if key is provided) |
- Source:
Methods
cancel(key)
If there is a timer assocaited with key, cancel it.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
* | name of the timer |
- Source:
cancelAll()
Cancels all existing timers. Any timer that is actively running or
has just terminated will be skipped and cleaned up in the _notFlapping
method.
- Source:
check(key, when, func, rescheduleopt, flappingFuncopt, nameopt, recreateopt)
If there is no timer associated with key, create one to expire at when and
call func (or #noop if func is null).
If there is a timer already associted with key, if reschedule is not
supplied or it's false cancel the timer. If reschedule is true, reschedule
the timer using when.
If there is a timer already associated with key, if a flappingFunc is
provided, call it.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
key |
string | the identifier of the timer in the TimerMgr instance | ||
when |
* | any representation of time of duration, see time.toZDT | ||
func |
function | function to call when the timer expires | ||
reschedule |
boolean |
<optional> |
false | optional flag, when present and true rescheudle the timer if it already exists |
flappingFunc |
function |
<optional> |
optional function to call when the timer already exists | |
name |
string |
<optional> |
timer name displayed in openHAB | |
recreate |
boolean |
<optional> |
false | optional flag, when present and true the timer will be recreated with the new values instead of cancelled, evaluated after reschedule |
- Source:
getTimerDuration(key) → {Duration}
Parameters:
| Name | Type | Description |
|---|---|---|
key |
* | name of the timer |
- Source:
Returns:
of time left in the timer function
or null if timer does not exist
- Type
- Duration
hasTimer(key) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
key |
* | name of the timer |
- Source:
Returns:
true if there is a timer assocaited with key
- Type
- boolean