Skip to content

Commit

Permalink
docs: add note for pollingInterval (alibaba#2358)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib authored Nov 19, 2023
1 parent b06cfea commit 978cb22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/hooks/src/useRequest/doc/polling/polling.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ You can experience the effect through the following example.

- `options.pollingInterval`, `options.pollingWhenHidden` support dynamic changes.
- If you set `options.manual = true`, the initialization will not start polling, you need start it by `run/runAsync`.
- If the `pollingInterval` changes from 0 to a value greater than 0, polling will not start automatically, and you need start it by `run/runAsync`.
- The polling logic is to wait for `pollingInterval` time after each request is completed, and then initiate the next request.
3 changes: 2 additions & 1 deletion packages/hooks/src/useRequest/doc/polling/polling.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ const { data, run, cancel } = useRequest(getUsername, {

| 参数 | 说明 | 类型 | 默认值 |
| ---------------------- | ------------------------------------------------------------------------------------------------------ | --------- | ------ |
| pollingInterval | 轮询间隔,单位为毫秒。如果值大于 0,则启动轮询模式| `number` | `0` |
| pollingInterval | 轮询间隔,单位为毫秒。如果值大于 0,则处于轮询模式| `number` | `0` |
| pollingWhenHidden | 在页面隐藏时,是否继续轮询。如果设置为 false,在页面隐藏时会暂时停止轮询,页面重新显示时继续上次轮询。 | `boolean` | `true` |
| pollingErrorRetryCount | 轮询错误重试次数。如果设置为 -1,则无限次 | `number` | `-1` |

## 备注

- `options.pollingInterval``options.pollingWhenHidden` 支持动态变化。
- 如果设置 `options.manual = true`,则初始化不会启动轮询,需要通过 `run/runAsync` 触发开始。
- 如果设置 `pollingInterval``0` 变成 `大于 0` 的值,不会启动轮询,需要通过 `run/runAsync` 触发开始。
- 轮询原理是在每次请求完成后,等待 `pollingInterval` 时间,发起下一次请求。

0 comments on commit 978cb22

Please sign in to comment.