new Polling(executor, optionsopt)
轮询类。
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
executor |
function | 执行函数,返回值为 Promise(带有 then 方法)时会进行异步处理。 | ||||||||||||||||
options |
Object |
<optional> |
其他选项。
Properties
|
- Source:
Example
const polling = new Polling(() => {
return new Promise((resolve) => {
setTimeout(() => {
console.log('executed');
resolve();
}, 1000);
});
}, {
interval: 2000
});
polling.start();
Methods
execImmediately()
在当前轮询结束后马上执行一次执行函数。
- Source:
start()
启动轮询。
- Source:
stop()
停止轮询。
- Source: