Skip to content

Commit a13cb49

Browse files
committed
feat: conditional client only async data
1 parent 8aebab9 commit a13cb49

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

packages/components-vue/src/components/loader/ContentFetch.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
isContent?: (c?: NoInfer<Ti>) => boolean;
8181
/** Ignore errors and display existing content */
8282
ignoreErrors?: boolean;
83+
/**
84+
* Whether to fetch data on client side only
85+
*/
86+
client?: boolean;
8387
}
8488
8589
/**
@@ -99,7 +103,7 @@
99103
100104
const { logger } = useHelpers(useUtils);
101105
const xamuOptions = inject<iVuePluginOptions>("xamu");
102-
const useAsyncData = xamuOptions?.asyncDataFn ?? useAsyncDataFn;
106+
const useAsyncData: typeof useAsyncDataFn = xamuOptions?.asyncDataFn ?? useAsyncDataFn;
103107
104108
const firstLoad = ref(false);
105109
const hydrated = ref(false);
@@ -182,6 +186,7 @@
182186
{
183187
default: () => props.fallback,
184188
watch: [() => props.url, () => props.preventAutoload],
189+
server: !props.client,
185190
}
186191
);
187192

packages/components-vue/src/components/pagination/Content.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
:promise="patchedPromise"
55
:payload="[{ ...pagination, ...defaults }]"
66
:class="$attrs.class"
7-
v-bind="{ preventAutoload, theme, noContentMessage, label, isContent, url, ignoreErrors }"
7+
v-bind="{
8+
preventAutoload,
9+
theme,
10+
noContentMessage,
11+
label,
12+
isContent,
13+
url,
14+
ignoreErrors,
15+
client,
16+
}"
817
@refresh="$emit('refresh', $event)"
918
>
1019
<slot
@@ -89,6 +98,10 @@
8998
* Ignore errors and display existing content.
9099
*/
91100
ignoreErrors?: boolean;
101+
/**
102+
* Whether to fetch data on client side only
103+
*/
104+
client?: boolean;
92105
}
93106
94107
/**

packages/components-vue/src/composables/async.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type AsyncDataOptions<T> = {
1111
default?: () => T | Ref<T> | null;
1212
transform?: (input: T) => T | Promise<T>;
1313
watch?: WatchSource[];
14+
server?: boolean;
1415
};
1516

1617
type tAsyncDataHandler<T> = (nuxtApp?: any) => Promise<T>;

0 commit comments

Comments
 (0)