feat(useQuery): prefetch option

This commit is contained in:
Guillaume Chau
2019-12-02 03:59:38 +01:00
parent b1cc1c9711
commit 151fbd2fc3
2 changed files with 5 additions and 0 deletions
+2
View File
@@ -34,6 +34,8 @@
- `notifyOnNetworkStatusChange`: Whether or not updates to the network status should trigger next on the observer of this query.
- `prefetch`: (default: `true`) Enable prefetching on the server during Server-Side Rendering.
- `pollInterval`: The time interval (in milliseconds) on which this query should be refetched from the server.
- `returnPartialData`: Allow returning incomplete data from the cache when a larger query cannot be fully satisfied by the cache, instead of returning nothing.
@@ -27,6 +27,7 @@ export interface UseQueryOptions<
enabled?: boolean
throttle?: number
debounce?: number
prefetch?: boolean
}
interface SubscribeToMoreItem {
@@ -93,6 +94,8 @@ export function useQuery<
*/
function start () {
if (started || !isEnabled.value) return
if (isServer && currentOptions.value.prefetch === false) return
started = true
loading.value = true