f / vue-wait

Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
MIT License
2k stars 100 forks source link

Add support of wildcards #16

Closed Koc closed 6 years ago

Koc commented 6 years ago

For example have 2 actions: addProductToCart, refreshCart. Each of they call startLoading(dispatcher, 'cart') on method enter and endLoading(dispatcher, 'cart') before each return. The problem occurs when addProductToCart calls refreshCart inside. End loading occurs too early.

It is similar to nested transactions.

f commented 6 years ago

Do not use same loading key for different actions. You should use startLoading(d, 'adding product to card') and startLoading(d, 'refreshing cart'). And you can watch $loader.isLoading(['adding product to cart', 'refreshing cart']) to wait both of loaders to be finished.

Koc commented 6 years ago

This can be sollution but not for all cases. For example we loading products

startLoading(dispatcher, `products.${id}`)

and I should make check for any loading products: $loader.isLoading('products.*') but asterisk syntax not supported.

f commented 6 years ago

@Koc this looks nice.

f commented 6 years ago

Please review v1.0.0 PR. It now supports RegExp check for isLoading.

isLoading(/products\..*/) will work.

Koc commented 6 years ago

covered by #31