shared-timers
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Shared Timers

[!WARNING] Mostly does not work on mobile https://caniuse.com/sharedworkers

Timers in SharedWorker, shared across browser tabs (within same origin). One timer per delay, many callbacks for each timer.

Motivation

Getting Started

Install using your preferred package manager, for example NPM:

npm install shared-timers

Use it in your project like this:

import { runTimer, clearTimer } from 'shared-timers'

const firstCallbackId = runTimer(() => {
    // Something executed periodically from a newly created `setInterval`.
}, 1000)

const secondCallbackId = runTimer(() => {
    // Something executed periodically from the same `setInterval`.
}, 1000)

// Remove callback from timer/execution.
clearTimer(secondCallbackId)

Package Sidebar

Install

npm i shared-timers

Weekly Downloads

6

Version

0.1.2

License

MIT

Unpacked Size

20.2 kB

Total Files

9

Last publish

Collaborators

  • crabvk