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

1.0.4 • Public • Published

GlobalTimer

GlobalTimer 可以使用webworker创建全局计时器,可以在多个组件内共享一个或多个计时器,到达预定时间会通过window.dispatchEvent进行通知。

安装

Using npm:

$ npm install globaltimer

or using yarn:

$ yarn add globaltimer

使用

//注册计时器
import globalTimer from 'globaltimer';
const timer = new globalTimer(5000, 'myTimer')
timer.start()

//组件内监听
window.addEventListener('myTimer', () => console.log(new Date(),'myTimer'))

Package Sidebar

Install

npm i globaltimer

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

15.1 kB

Total Files

8

Last publish

Collaborators

  • weibinxd