diff options
author | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2018-04-25 19:45:34 +0300 |
---|---|---|
committer | Ujjwal Sharma <usharma1998@gmail.com> | 2018-05-10 19:49:27 +0300 |
commit | 46d335c380510fda68e62a4cdafa58e7e7b230a1 (patch) | |
tree | 6bf18decea35ca947eb61174de00e5b6335fbce5 /doc/api/timers.md | |
parent | d9425733931d86b41cbe0cb7f7f9940af4cbe8a5 (diff) |
timers: make timer.refresh() a public API
Originally added in
bb5575aa75fd3071724d5eccde39a3041e1af57a
discussions such as
https://github.com/nodejs/node/issues/20261
show the usefulness of this API to the Node.js ecosystem.
PR-URL: https://github.com/nodejs/node/pull/20298
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'doc/api/timers.md')
-rw-r--r-- | doc/api/timers.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/api/timers.md b/doc/api/timers.md index 376b5312e5a..c573d2afdb9 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -74,6 +74,21 @@ When called, requests that the Node.js event loop *not* exit so long as the By default, all `Timeout` objects are "ref'ed", making it normally unnecessary to call `timeout.ref()` unless `timeout.unref()` had been called previously. +### timeout.refresh() +<!-- YAML +added: REPLACEME +--> + +* Returns: {Timeout} a reference to `timeout` + +Sets the timer's start time to the current time, and 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. + ### timeout.unref() <!-- YAML added: v0.9.1 |