Skip to content
/ heartbeat Public

Combine multiple recurring timers to a single interval

Notifications You must be signed in to change notification settings

mixu/heartbeat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maintains a single interval, which is used to trigger tasks.

This is useful for something like:

  • sending heartbeat messages
  • performing cleanup operations occasionally

API

heartbeat.interval(ms)

Set the interval lenght for the heartbeat.

heartbeat.start() / heartbeat.resume()

Start or resume the heartbeat.

heartbeat.nextTimeout(millis)

Change the trigger time of the next timeout. For example, in order to guarantee that first heartbeat occurs within a shorter amount of time than average.

heartbeat.add(cb)

Add a callback to the heartbeat actions.

heartbeat.remove(cb)

Remove a callback from the heartbeat actions.

heartbeat.pause()

Pause the heartbeat.

heartbeat.clear()

Clear the heartbeat and all callback actions.

About

Combine multiple recurring timers to a single interval

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published