Skip to content

Commit 87cf9a3

Browse files
committed
ApolloProvider: New waitForLoaded option
1 parent 76e41f4 commit 87cf9a3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/apollo-provider.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ export class ApolloProvider {
88
this._collecting = false
99
}
1010

11-
collect () {
11+
collect (options) {
12+
const finalOptions = Object.assign({}, {
13+
waitForLoaded: true,
14+
}, options)
1215
this._promises = []
16+
this._collectingOptions = finalOptions
1317
this._isCollecting = true
1418
return () => this._ensureReady()
1519
}

src/dollar-apollo.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export class DollarApollo {
2121
this.provider._waitFor(new Promise((resolve, reject) => {
2222
sub = query.subscribe({
2323
next: result => {
24-
resolve(result)
24+
if (!this.provider._collectingOptions.waitForLoaded || !result.loading) {
25+
resolve(result)
26+
}
2527
},
2628
error: error => {
2729
reject(error)

0 commit comments

Comments
 (0)