0👍
If you are talking about a few component loading simultaneously then the best way would be using vuex.
You can store to vuex 2 values: isLoading
and countLoadingComponents
.
You can increment countLoadingComponents
at beginning of created()
method of each component and decrement countLoadingComponents
when API call within that component is finished.
Create watcher
for countLoadingComponents
state in the main component. If countLoadingComponents
equal 0, then change state of isLoading
to false
.
Source:stackexchange.com