1.1.0 • Published 8 months ago

pr-interval-queue v1.1.0

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

一个简单的全局事件循环队列

使用方法

npm i pr-interval-queue

按需引入

import { removeQueueItem, addQueueItem, startQueue } from 'pr-interval-queue'

main.js 中开启队列

startQueue(1000, true) // 循环频率ms,是否开启调试

简单使用

// 需要执行的函数
const func = () => {}
// 添加一个事件10000ms执行一次
addQueueItem({ func, interval: 10000 })

指定事件 key

// 需要执行的函数
const func = () => {}

// 指定事件key (重复添加相同事件会清除上一个)
addQueueItem({ func, interval: 3000, key: 'bbb-3' })

在未来添加一个循环事件

// 需要执行的函数
const func = () => {}

// 给一天后添加一个每6000ms的循环事件
addQueueItem({ func, interval: 6000, key: 'ccc-6', execution_time: new Date().getTime() + 1000 * 60 * 60 * 24 * 1 })

移除事件

// 需要执行的函数
const func = () => {}

// 保存添加后的key 如果不指定key,会随机生成一个并返回
const key = addQueueItem({ func, interval: 3000 })
removeQueueItem([key])

代码仓库

github

贡献

breathe

1.1.0

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.6

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago