ApolloProvider: New waitForLoaded option

This commit is contained in:
Guillaume Chau
2017-04-04 00:24:58 +02:00
parent 76e41f41ed
commit 87cf9a3582
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -8,8 +8,12 @@ export class ApolloProvider {
this._collecting = false
}
collect () {
collect (options) {
const finalOptions = Object.assign({}, {
waitForLoaded: true,
}, options)
this._promises = []
this._collectingOptions = finalOptions
this._isCollecting = true
return () => this._ensureReady()
}
+3 -1
View File
@@ -21,7 +21,9 @@ export class DollarApollo {
this.provider._waitFor(new Promise((resolve, reject) => {
sub = query.subscribe({
next: result => {
resolve(result)
if (!this.provider._collectingOptions.waitForLoaded || !result.loading) {
resolve(result)
}
},
error: error => {
reject(error)