Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
Setting the enabled flag to the same as it's current value has no effect, setting to true
when already true
will not refresh() the timer.
And setting to 'false` will cancel() the timer.
let theTimer = createTimeout(...);
// Check if enabled
theTimer.enabled; // false
// Start the timer
theTimer.enabled = true; // Same as calling refresh()
theTimer.enabled; //true
// Has no effect as it's already running
theTimer.enabled = true;
// Will refresh / restart the time
theTimer.refresh()
let theTimer = scheduleTimeout(...);
// Check if enabled
theTimer.enabled; // true
When called, requests that the event loop not exit so long when the ITimerHandler is active. Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless timer.unref() had been called previously.
the ITimerHandler instance
Reschedules the timer to call its callback at the previously specified duration adjusted to the current time. This is useful for refreshing a timer without allocating a new JavaScript object.
Using this on a timer that has already called its callback will reactivate the timer. Calling on a timer that has not yet executed will just reschedule the current timer.
When called, the any active ITimerHandler instance will not require the event loop to remain active (Node.js). If there is no other activity keeping the event loop running, the process may exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times will have no effect.
the ITimerHandler instance
A Timer handler which is returned from scheduleTimeout which contains functions to cancel or restart (refresh) the timeout function.
Since
0.4.4