@@ -13,6 +13,9 @@ export default function (Vue) {
1313 [ initHook ] : beforeCreate ( Vue ) ,
1414 created : created ( ) ,
1515 beforeDestroy : beforeDestroy ( ) ,
16+ computed : {
17+ $loadingSyncers : loadingStateGetter
18+ } ,
1619 methods : {
1720 $refreshSyncers : refreshSyncers
1821 }
@@ -44,13 +47,6 @@ function beforeCreate(Vue) {
4447 configurable : true
4548 } )
4649 } )
47-
48- // Add state that tells if all are loaded
49- Vue . util . defineReactive ( this , '$loadingSyncers' , true )
50- // The watcher for this is in created() as $watch doesn't work this early
51- } else {
52- // Never will change
53- this . $loadingSyncers = false
5450 }
5551 }
5652}
@@ -64,18 +60,6 @@ function created() {
6460 each ( this . _syncers , syncer => {
6561 syncer . ready ( )
6662 } )
67-
68- if ( Object . keys ( this . _syncers ) . length > 0 ) {
69- // Watcher for $loadingSyncers
70- this . $watch ( function ( ) {
71- // If any are true
72- return some ( this . _syncers , syncer => {
73- return 'loading' in syncer ? syncer . loading : false
74- } )
75- } , newVal => {
76- this . $loadingSyncers = newVal
77- } , { sync : true , immediate : true } )
78- }
7963 }
8064}
8165
@@ -91,6 +75,20 @@ function beforeDestroy() {
9175 }
9276}
9377
78+ /**
79+ * Get loading state of the syncers
80+ *
81+ * @returns {boolean }
82+ */
83+ function loadingStateGetter ( ) {
84+ if ( Object . keys ( this . _syncers ) . length > 0 ) {
85+ return some ( this . _syncers , syncer => {
86+ return syncer . loading
87+ } )
88+ }
89+ return false
90+ }
91+
9492/**
9593 * Refresh syncers state
9694 *
0 commit comments