Skip to content

Commit 9963deb

Browse files
committed
refactor: update readme and index types to replace 'pending' with 'status'
1 parent 138cd1d commit 9963deb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

readme.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,26 @@ import { ref } from 'vue';
8888
const id = ref(1);
8989
9090
// Function without arguments
91-
const { data: dataList, pending: listPending, error: listError } = wrappedService.fetchData();
91+
const { data: dataList, status: listStatus, error: listError } = wrappedService.fetchData();
9292
9393
// Function with arguments
94-
const { data: itemData, pending: itemPending, error: itemError } = wrappedService.getItem(() => [id.value]);
94+
const { data: itemData, status: itemStatus, error: itemError } = wrappedService.getItem(() => [id.value]);
9595
9696
// Reactivity: when id.value changes, itemData updates automatically
9797
</script>
9898
9999
<template>
100100
<div>
101101
<h1>Data List</h1>
102-
<div v-if="listPending">Loading...</div>
102+
<div v-if="listStatus === 'pending'">Loading...</div>
103103
<div v-else-if="listError">Error: {{ listError.message }}</div>
104104
<div v-else>
105105
<pre>{{ dataList }}</pre>
106106
</div>
107107
108108
<h1>Item Data (ID: {{ id }})</h1>
109109
<input v-model="id" type="number" min="1" />
110-
<div v-if="itemPending">Loading...</div>
110+
<div v-if="itemStatus === 'pending'">Loading...</div>
111111
<div v-else-if="itemError">Error: {{ itemError.message }}</div>
112112
<div v-else>
113113
<pre>{{ itemData }}</pre>
@@ -160,7 +160,7 @@ async function fetchData() {
160160
const wrappedService = useAsyncDataWrapper({ fetchData });
161161

162162
// Use in a component
163-
const { data, pending, error } = wrappedService.fetchData();
163+
const { data, status, error } = wrappedService.fetchData();
164164
```
165165

166166
### Function With Arguments
@@ -179,7 +179,7 @@ import { ref } from 'vue';
179179

180180
const id = ref(1);
181181

182-
const { data, pending, error } = wrappedService.getItem(() => [id.value]);
182+
const { data, status, error } = wrappedService.getItem(() => [id.value]);
183183

184184
// When id.value changes, data is automatically refreshed
185185
```
@@ -193,7 +193,7 @@ You can pass options to `useAsyncData` through the wrapped functions to control
193193
### Example with Options
194194

195195
```typescript
196-
const { data, pending, error } = wrappedService.fetchData({
196+
const { data, status, error } = wrappedService.fetchData({
197197
lazy: true,
198198
server: false,
199199
default: () => [],

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ export type AsyncDataWrapper<T> = {
2626
? /**
2727
* Functions without arguments.
2828
* @param options - Optional AsyncDataOptions to configure useAsyncData.
29-
* @returns AsyncDataResult containing the data, pending state, and error.
29+
* @returns AsyncDataResult containing the data, status state, and error.
3030
*/
3131
(options?: AsyncDataOptions<R>) => AsyncDataResult<R>
3232
: /**
3333
* Functions with arguments.
3434
* @param argsSupplier - A function that returns the arguments array for the original function.
3535
* @param options - Optional AsyncDataOptions to configure useAsyncData.
36-
* @returns AsyncDataResult containing the data, pending state, and error.
36+
* @returns AsyncDataResult containing the data, status state, and error.
3737
*/
3838
(
3939
argsSupplier: () => Args,

0 commit comments

Comments
 (0)