Skip to content

Commit 9c4b6b0

Browse files
author
Guillaume Chau
committed
fix: use onBeforeUnmount
1 parent 2a9ca9f commit 9c4b6b0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/vue-apollo-composable/src/useMutation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DocumentNode } from 'graphql'
22
import { MutationOptions, OperationVariables } from 'apollo-client'
3-
import { ref } from '@vue/composition-api'
3+
import { ref, onBeforeUnmount } from '@vue/composition-api'
44
import { FetchResult } from 'apollo-link'
55
import { useApolloClient } from './useApolloClient'
66
import { ReactiveFunction } from './util/ReactiveFunction'
@@ -73,6 +73,10 @@ export function useMutation<
7373
}
7474
}
7575

76+
onBeforeUnmount(() => {
77+
loading.value = false
78+
})
79+
7680
return {
7781
mutate,
7882
loading,

packages/vue-apollo-composable/src/useQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, Ref, isRef, computed, watch, onServerPrefetch, onUnmounted, getCurrentInstance } from '@vue/composition-api'
1+
import { ref, Ref, isRef, computed, watch, onServerPrefetch, getCurrentInstance, onBeforeUnmount } from '@vue/composition-api'
22
import Vue from 'vue'
33
import { DocumentNode } from 'graphql'
44
import {
@@ -373,7 +373,7 @@ export function useQuery<
373373
})
374374

375375
// Teardown
376-
onUnmounted(() => {
376+
onBeforeUnmount(() => {
377377
stop()
378378
subscribeToMoreItems.length = 0
379379
})

packages/vue-apollo-composable/src/useSubscription.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DocumentNode } from 'graphql'
22
import Vue from 'vue'
3-
import { Ref, ref, watch, isRef, onUnmounted, computed, getCurrentInstance } from '@vue/composition-api'
3+
import { Ref, ref, watch, isRef, computed, getCurrentInstance, onBeforeUnmount } from '@vue/composition-api'
44
import { OperationVariables, SubscriptionOptions } from 'apollo-client'
55
import { Observable, Subscription } from 'apollo-client/util/Observable'
66
import { FetchResult } from 'apollo-link'
@@ -188,7 +188,7 @@ export function useSubscription <
188188
})
189189

190190
// Teardown
191-
onUnmounted(stop)
191+
onBeforeUnmount(stop)
192192

193193
return {
194194
result,

0 commit comments

Comments
 (0)