File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -400,7 +400,7 @@ class Store extends Base {
400400 onCollectionMutate ( opts ) {
401401 let me = this ;
402402
403- if ( me . configsApplied && ! me . isLoading ) {
403+ if ( me . isConstructed && ! me . isLoading ) {
404404 me . fire ( 'load' , me . items )
405405 }
406406 }
@@ -411,9 +411,8 @@ class Store extends Base {
411411 onCollectionSort ( ) {
412412 let me = this ;
413413
414- if ( me . configsApplied ) {
415- // console.log('onCollectionSort', me.collection.items);
416- // me.fire('load', me.items);
414+ if ( me . isConstructed ) {
415+ me . fire ( 'load' , me . items )
417416 }
418417 }
419418
@@ -429,11 +428,15 @@ class Store extends Base {
429428 me . afterSetData ( me . data ) ;
430429 }
431430
432- if ( me . autoLoad ) {
433- me . timeout ( 100 ) . then ( ( ) => { // todo
431+ // Being constructed does not mean that related afterSetStore() methods got executed
432+ // => break the sync flow to ensure potential listeners got applied
433+ Promise . resolve ( ) . then ( ( ) => {
434+ if ( me . getCount ( ) > 0 ) {
435+ me . fire ( 'load' , me . items )
436+ } else if ( me . autoLoad ) {
434437 me . load ( )
435- } )
436- }
438+ }
439+ } )
437440 }
438441
439442 /**
You can’t perform that action at this time.
0 commit comments