Skip to content

引入

ts
import { PollingRequest  } from 't-comm';

// 不支持 tree-shaking 的项目
import { PollingRequest } from 't-comm/lib/polling/index';

// 只支持 ESM 的项目
import { PollingRequest } from 't-comm/es/polling/index';

PollingRequest

参数

new PollingRequest([maxPollingTime], [timeInterval])

轮询

ParamTypeDefaultDescription
[maxPollingTime]number10

最大轮询次数

[timeInterval]number2000

轮询间隔

Example

ts
const polling = new PollingRequest(10);
const cb = () => {
  this.onGetTeamList(true);
};
polling.polling(cb);

pollingRequest.reset()

重置,即取消轮询

Kind: instance method of PollingRequest

pollingRequest.polling(func)

开始轮询

Kind: instance method of PollingRequest

ParamTypeDescription
funcfunction

轮询方法