Skip to content

Commit fa450d0

Browse files
author
Guillaume Chau
committed
Now supports multiple subscribeToMore on query
1 parent ce7c2ce commit fa450d0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ apollo: {
743743
}
744744
```
745745

746+
*Note that you can pass an array of subscriptions to `subscribeToMore` to subscribe to multiple subcribtions on this query.*
747+
746748
#### Alternate usage
747749

748750
You can access the queries you defined in the `apollo` option with `this.$apollo.queries.<name>`, so it would look like this:

src/dollar-apollo.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,21 @@ export class DollarApollo {
7777
const smart = this.queries[key] = new SmartQuery(this.vm, key, options, false)
7878
smart.autostart()
7979

80-
if (options.subscribeToMore) {
81-
this.addSmartSubscription(key, {
82-
...options.subscribeToMore,
83-
linkedQuery: smart,
84-
})
80+
const subs = options.subscribeToMore
81+
if (subs) {
82+
if (Array.isArray(subs)) {
83+
subs.forEach((sub, index) => {
84+
this.addSmartSubscription(`${key}${index}`, {
85+
...sub,
86+
linkedQuery: smart,
87+
})
88+
})
89+
} else {
90+
this.addSmartSubscription(key, {
91+
...subs,
92+
linkedQuery: smart,
93+
})
94+
}
8595
}
8696

8797
return smart

0 commit comments

Comments
 (0)