Skip to content

Commit 4612b06

Browse files
author
Guillaume Chau
committed
Fix #49
1 parent e29090f commit 4612b06

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-apollo",
3-
"version": "2.1.0-beta.3",
3+
"version": "2.1.0-beta.4",
44
"description": "Vue apollo integration",
55
"main": "lib/index.js",
66
"scripts": {

src/dollar-apollo.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,17 @@ export class DollarApollo {
9696
}
9797

9898
option (key, options) {
99-
this.queries[key] = new SmartQuery(this.vm, key, options)
99+
const smart = this.queries[key] = new SmartQuery(this.vm, key, options, false)
100+
this.vm.$nextTick(() => {
101+
smart.autostart()
102+
})
100103
}
101104

102105
subscribeOption (key, options) {
103-
this.subscriptions[key] = new SmartSubscription(this.vm, key, options)
106+
const smart = this.subscriptions[key] = new SmartSubscription(this.vm, key, options, false)
107+
this.vm.$nextTick(() => {
108+
smart.autostart()
109+
})
104110
}
105111

106112
defineReactiveSetter (key, func) {

src/smart-apollo.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class SmartApollo {
55
type = null
66
vueApolloSpecialKeys = []
77

8-
constructor (vm, key, options) {
8+
constructor (vm, key, options, autostart = true) {
99
this.vm = vm
1010
this.key = key
1111
this.options = options
@@ -22,7 +22,9 @@ class SmartApollo {
2222
}))
2323
}
2424

25-
this.autostart()
25+
if (autostart) {
26+
this.autostart()
27+
}
2628
}
2729

2830
autostart () {
@@ -148,7 +150,7 @@ export class SmartQuery extends SmartApollo {
148150
'debounce',
149151
]
150152

151-
constructor (vm, key, options) {
153+
constructor (vm, key, options, autostart = true) {
152154
// Options object callback
153155
while (typeof options === 'function') {
154156
options = options.call(vm)
@@ -162,7 +164,7 @@ export class SmartQuery extends SmartApollo {
162164
}
163165
}
164166

165-
super(vm, key, options)
167+
super(vm, key, options, autostart)
166168
}
167169

168170
stop () {
@@ -307,13 +309,13 @@ export class SmartSubscription extends SmartApollo {
307309
'debounce',
308310
]
309311

310-
constructor (vm, key, options) {
312+
constructor (vm, key, options, autostart = true) {
311313
// Options object callback
312314
while (typeof options === 'function') {
313315
options = options.call(vm)
314316
}
315317

316-
super(vm, key, options)
318+
super(vm, key, options, autostart)
317319
}
318320

319321
executeApollo (variables) {

0 commit comments

Comments
 (0)