🎨 Improve code formatting and readability in useAsyncState composable
This commit is contained in:
@@ -27,9 +27,13 @@ export function useAsyncState(options = {}) {
|
|||||||
const data = ref(initialData);
|
const data = ref(initialData);
|
||||||
const abortController = ref(null);
|
const abortController = ref(null);
|
||||||
|
|
||||||
const isSuccess = computed(() => !loading.value && !error.value && data.value !== null);
|
const isSuccess = computed(
|
||||||
|
() => !loading.value && !error.value && data.value !== null
|
||||||
|
);
|
||||||
const isError = computed(() => !loading.value && error.value !== null);
|
const isError = computed(() => !loading.value && error.value !== null);
|
||||||
const isIdle = computed(() => !loading.value && error.value === null && data.value === null);
|
const isIdle = computed(
|
||||||
|
() => !loading.value && error.value === null && data.value === null
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute an async function with state management
|
* Execute an async function with state management
|
||||||
@@ -74,7 +78,9 @@ export function useAsyncState(options = {}) {
|
|||||||
|
|
||||||
// If more retries remaining, wait before retrying
|
// If more retries remaining, wait before retrying
|
||||||
if (attempt <= retries) {
|
if (attempt <= retries) {
|
||||||
await new Promise(resolve => setTimeout(resolve, retryDelay * attempt));
|
await new Promise(resolve =>
|
||||||
|
setTimeout(resolve, retryDelay * attempt)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user