@stream-io/worker-timer
v1.2.5
Published
Worker based timers for Stream.io JS-based SDKs and applications
Readme
@stream-io/worker-timer
A Worker based implementation of the JS Timers API.
Usage
// import the library
import { WorkerTimer } from "@stream-io/worker-timer";
// create an instance
const timer = new WorkerTimer();
// with interval
const id = timer.setInterval(() => {
console.log("Hello World from interval");
}, 1000);
// clear the interval
timer.clearInterval(id);
// with timeout
timer.setTimeout(() => {
console.log("Hello World from timeout");
}, 1000);
// clear the timeout
timer.clearTimeout(id);Advanced usage
You can also create a WorkerTimer instance with custom defaults:
const timer = new WorkerTimer({
useWorker: false, // will fallback the Platform API
name: "custom-timer", // name of the worker, for debugging purposes
});