Skip to content

Commit 9546360

Browse files
author
Guillaume Chau
committed
fix: should properly stop and restart subcribe to more subs after query is restarted, closes #677
1 parent 970dc2b commit 9546360

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/dollar-apollo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ export class DollarApollo {
150150
const smart = this.subscriptions[key] = new SmartSubscription(this.vm, key, options, false)
151151
smart.autostart()
152152

153+
if (options.linkedQuery) {
154+
options.linkedQuery._linkedSubscriptions.push(smart)
155+
}
156+
153157
return smart
154158
}
155159
}

src/smart-query.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default class SmartQuery extends SmartApollo {
55
type = 'query'
66
vueApolloSpecialKeys = VUE_APOLLO_QUERY_KEYWORDS
77
_loading = false
8+
_linkedSubscriptions = []
89

910
constructor (vm, key, options, autostart = true) {
1011
// Add reactive data related to the query
@@ -86,6 +87,11 @@ export default class SmartQuery extends SmartApollo {
8687
return
8788
}
8889
this.sub.unsubscribe()
90+
91+
// Subscribe to more subs
92+
for (const sub of this._linkedSubscriptions) {
93+
sub.stop()
94+
}
8995
}
9096

9197
this.previousVariablesJson = variablesJson
@@ -104,6 +110,11 @@ export default class SmartQuery extends SmartApollo {
104110
}
105111

106112
super.executeApollo(variables)
113+
114+
// Subscribe to more subs
115+
for (const sub of this._linkedSubscriptions) {
116+
sub.start()
117+
}
107118
}
108119

109120
startQuerySubscription () {

0 commit comments

Comments
 (0)