@@ -113,9 +113,11 @@ export default class SmartQuery extends SmartApollo {
113113 this . startQuerySubscription ( )
114114
115115 if ( this . options . fetchPolicy !== 'no-cache' || this . options . notifyOnNetworkStatusChange ) {
116- const currentResult = this . maySetLoading ( )
116+ const currentResult = this . retrieveCurrentResult ( )
117117
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 ) ) {
119121 this . nextResult ( currentResult )
120122 }
121123 }
@@ -138,7 +140,10 @@ export default class SmartQuery extends SmartApollo {
138140 } )
139141 }
140142
141- maySetLoading ( force = false ) {
143+ /**
144+ * May update loading state
145+ */
146+ retrieveCurrentResult ( force = false ) {
142147 const currentResult = this . observer . getCurrentResult ? this . observer . getCurrentResult ( ) : this . observer . currentResult ( )
143148 if ( force || currentResult . loading ) {
144149 if ( ! this . loading ) {
@@ -259,7 +264,7 @@ export default class SmartQuery extends SmartApollo {
259264
260265 fetchMore ( ...args ) {
261266 if ( this . observer ) {
262- this . maySetLoading ( true )
267+ this . retrieveCurrentResult ( true )
263268 return this . observer . fetchMore ( ...args ) . then ( result => {
264269 if ( ! result . loading ) {
265270 this . loadingDone ( )
@@ -286,7 +291,7 @@ export default class SmartQuery extends SmartApollo {
286291 }
287292 return result
288293 } )
289- this . maySetLoading ( )
294+ this . retrieveCurrentResult ( )
290295 return result
291296 }
292297 }
@@ -295,7 +300,7 @@ export default class SmartQuery extends SmartApollo {
295300 this . options . variables = variables
296301 if ( this . observer ) {
297302 const result = this . observer . setVariables ( variables , tryFetch )
298- this . maySetLoading ( )
303+ this . retrieveCurrentResult ( )
299304 return result
300305 }
301306 }
@@ -304,7 +309,7 @@ export default class SmartQuery extends SmartApollo {
304309 Object . assign ( this . options , options )
305310 if ( this . observer ) {
306311 const result = this . observer . setOptions ( options )
307- this . maySetLoading ( )
312+ this . retrieveCurrentResult ( )
308313 return result
309314 }
310315 }
0 commit comments