🎨 Improve code formatting and readability in useAsyncState composable
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* useAsyncState Composable
|
||||
*
|
||||
*
|
||||
* Manages loading/error/success states for async operations
|
||||
* Consolidates pattern used across 13+ components
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* const { execute, loading, error, data, isSuccess } = useAsyncState();
|
||||
* await execute(async () => {
|
||||
@@ -27,9 +27,13 @@ export function useAsyncState(options = {}) {
|
||||
const data = ref(initialData);
|
||||
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 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
|
||||
@@ -74,7 +78,9 @@ export function useAsyncState(options = {}) {
|
||||
|
||||
// If more retries remaining, wait before retrying
|
||||
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