Now supports multiple subscribeToMore on query

This commit is contained in:
Guillaume Chau
2017-08-28 15:59:27 +02:00
parent ce7c2cecbe
commit fa450d0ff2
2 changed files with 17 additions and 5 deletions
+2
View File
@@ -743,6 +743,8 @@ apollo: {
}
```
*Note that you can pass an array of subscriptions to `subscribeToMore` to subscribe to multiple subcribtions on this query.*
#### Alternate usage
You can access the queries you defined in the `apollo` option with `this.$apollo.queries.<name>`, so it would look like this:
+15 -5
View File
@@ -77,11 +77,21 @@ export class DollarApollo {
const smart = this.queries[key] = new SmartQuery(this.vm, key, options, false)
smart.autostart()
if (options.subscribeToMore) {
this.addSmartSubscription(key, {
...options.subscribeToMore,
linkedQuery: smart,
})
const subs = options.subscribeToMore
if (subs) {
if (Array.isArray(subs)) {
subs.forEach((sub, index) => {
this.addSmartSubscription(`${key}${index}`, {
...sub,
linkedQuery: smart,
})
})
} else {
this.addSmartSubscription(key, {
...subs,
linkedQuery: smart,
})
}
}
return smart