Skip to content

Commit

Permalink
fix: don't call refresh and retry while pending
Browse files Browse the repository at this point in the history
  • Loading branch information
dongnaebi committed Mar 26, 2023
1 parent d126afe commit 5f252be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/axues/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export function createAxues (axiosInstance: AxiosInstance, createOptions?: Creat
let lastPayload: TAction
const refresh = () => {
return new CancelablePromise<TO>((resolve, reject, cancel) => {
if (refreshing.value) return cancel()
if (pending.value) return cancel()
onAction?.('refresh')
// keep state when refresh
// data.value = initialData
Expand All @@ -342,7 +342,7 @@ export function createAxues (axiosInstance: AxiosInstance, createOptions?: Creat

const retry = () => {
return new CancelablePromise<TO>((resolve, reject, cancel) => {
if (retrying.value) return cancel()
if (pending.value) return cancel()
if (!error.value) {
throw new Error('Retry can only be called on error state')
}
Expand Down

0 comments on commit 5f252be

Please sign in to comment.