Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(useRequest): add note for pollingInterval #2358

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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` 时间,发起下一次请求。
Loading