Skip to content

Commit

Permalink
fix: 300ms is better
Browse files Browse the repository at this point in the history
  • Loading branch information
dongnaebi committed Mar 12, 2023
1 parent 156d7dd commit 6fde50a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/axues/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function createAxues (axiosInstance: AxiosInstance, createOptions?: Creat
immediate = rewriteDefault?.immediate || false,
initialData = null as TO,
shallow = rewriteDefault?.shallow || false,
loadingDelay = rewriteDefault?.loadingDelay || deprecatedLoadingDelay || 200,
loadingDelay = rewriteDefault?.loadingDelay || deprecatedLoadingDelay || 300,
debounceMode = 'firstPass',
debounce = rewriteDefault?.debounce,
debounceTime = rewriteDefault?.debounceTime || 500,
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/zh/guide/request-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ action(2) // 将发起请求:/api/user/2

## loadingDelay

配置 loading 状态的延迟,上一章节我们讲过,当请求发起时,`pending` 会立即变为 `true`,而 `loading` 会延迟 200ms(默认)后变为 `true`,如果你觉得 200ms 不太合理,那么你可以更改 `loadingDelay` 的值。
配置 loading 状态的延迟,上一章节我们讲过,当请求发起时,`pending` 会立即变为 `true`,而 `loading` 会延迟 300ms(默认)后变为 `true`,如果你觉得 300ms 不太合理,那么你可以更改 `loadingDelay` 的值。

```javascript
import { useAxues } from 'axues'
const { loading, success, error, data } = useAxues({
url: '/api/foo',
loadingDelay: 300
loadingDelay: 200
})
```

Expand Down
6 changes: 3 additions & 3 deletions packages/docs/zh/guide/request-states-and-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ action(2)

## 请求中(pending & loading)

请求发起到请求完成,中间的状态就是请求中状态,Axues 有两个请求中状态:`pending``loading`,默认都为 `false`。当发起请求时,`pending` 会立即变为 `true`,而 `loading` 会延迟 200ms(默认,[可配置]())后变为 `true`,当请求完成后,又会重置为 `false`
请求发起到请求完成,中间的状态就是请求中状态,Axues 有两个请求中状态:`pending``loading`,默认都为 `false`。当发起请求时,`pending` 会立即变为 `true`,而 `loading` 会延迟 300ms(默认,[可配置](./request-configuration#loadingdelay))后变为 `true`,当请求完成后,又会重置为 `false`

```javascript
import { useAxues } from 'axues'
Expand All @@ -65,10 +65,10 @@ console.log(pending.value, loading.value) // false, false
action()
console.log(pending.value, loading.value) // true, false

// 假设请求超过200ms
// 假设请求超过300ms
setTimeout(() => {
console.log(pending.value, loading.value) // true, true
}, 200)
}, 300)
```

::: tip 为什么要用两个状态来标识请求中?
Expand Down

0 comments on commit 6fde50a

Please sign in to comment.