JSPM

shared-timers

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q15002F
  • License MIT

Unthrottleable timers that work across tabs.

Package Exports

  • shared-timers
  • shared-timers/dist/shared-timers.js
  • shared-timers/dist/shared-timers.umd.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (shared-timers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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)