@@ -113,9 +113,11 @@ export default class SmartQuery extends SmartApollo {
113
113
this . startQuerySubscription ( )
114
114
115
115
if ( this . options . fetchPolicy !== 'no-cache' || this . options . notifyOnNetworkStatusChange ) {
116
- const currentResult = this . maySetLoading ( )
116
+ const currentResult = this . retrieveCurrentResult ( )
117
117
118
- if ( this . options . notifyOnNetworkStatusChange ) {
118
+ if ( this . options . notifyOnNetworkStatusChange ||
119
+ // Initial call of next result when it's not loading (for Apollo Client 3)
120
+ ( this . observer . getCurrentResult && ! currentResult . loading ) ) {
119
121
this . nextResult ( currentResult )
120
122
}
121
123
}
@@ -138,7 +140,10 @@ export default class SmartQuery extends SmartApollo {
138
140
} )
139
141
}
140
142
141
- maySetLoading ( force = false ) {
143
+ /**
144
+ * May update loading state
145
+ */
146
+ retrieveCurrentResult ( force = false ) {
142
147
const currentResult = this . observer . getCurrentResult ? this . observer . getCurrentResult ( ) : this . observer . currentResult ( )
143
148
if ( force || currentResult . loading ) {
144
149
if ( ! this . loading ) {
@@ -259,7 +264,7 @@ export default class SmartQuery extends SmartApollo {
259
264
260
265
fetchMore ( ...args ) {
261
266
if ( this . observer ) {
262
- this . maySetLoading ( true )
267
+ this . retrieveCurrentResult ( true )
263
268
return this . observer . fetchMore ( ...args ) . then ( result => {
264
269
if ( ! result . loading ) {
265
270
this . loadingDone ( )
@@ -286,7 +291,7 @@ export default class SmartQuery extends SmartApollo {
286
291
}
287
292
return result
288
293
} )
289
- this . maySetLoading ( )
294
+ this . retrieveCurrentResult ( )
290
295
return result
291
296
}
292
297
}
@@ -295,7 +300,7 @@ export default class SmartQuery extends SmartApollo {
295
300
this . options . variables = variables
296
301
if ( this . observer ) {
297
302
const result = this . observer . setVariables ( variables , tryFetch )
298
- this . maySetLoading ( )
303
+ this . retrieveCurrentResult ( )
299
304
return result
300
305
}
301
306
}
@@ -304,7 +309,7 @@ export default class SmartQuery extends SmartApollo {
304
309
Object . assign ( this . options , options )
305
310
if ( this . observer ) {
306
311
const result = this . observer . setOptions ( options )
307
- this . maySetLoading ( )
312
+ this . retrieveCurrentResult ( )
308
313
return result
309
314
}
310
315
}
0 commit comments