Skip to content

Commit

Permalink
fix(useSbuscription): currentOptions undefined error, closes #903
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jan 10, 2020
1 parent 23c7f66 commit fb1565d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/vue-apollo-composable/src/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ export function useSubscription <
debouncedRestart()
}

// Applying options
const currentOptions = ref<UseSubscriptionOptions<TResult, TVariables>>()
watch(() => isRef(optionsRef) ? optionsRef.value : optionsRef, value => {
if (currentOptions.value && (
currentOptions.value.throttle !== value.throttle ||
currentOptions.value.debounce !== value.debounce
)) {
updateRestartFn()
}
currentOptions.value = value
restart()
}, {
deep: true,
})

// Applying document
let currentDocument: DocumentNode
watch(documentRef, value => {
Expand All @@ -150,21 +165,6 @@ export function useSubscription <
deep: true,
})

// Applying options
const currentOptions = ref<UseSubscriptionOptions<TResult, TVariables>>()
watch(() => isRef(optionsRef) ? optionsRef.value : optionsRef, value => {
if (currentOptions.value && (
currentOptions.value.throttle !== value.throttle ||
currentOptions.value.debounce !== value.debounce
)) {
updateRestartFn()
}
currentOptions.value = value
restart()
}, {
deep: true,
})

// Internal enabled returned to user
// @TODO Doesn't fully work yet, need to initialize with option
// const enabled = ref<boolean>()
Expand Down

0 comments on commit fb1565d

Please sign in to comment.