Closed Koc closed 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.
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.
@Koc this looks nice.
Please review v1.0.0 PR. It now supports RegExp check for isLoading
.
isLoading(/products\..*/)
will work.
covered by #31
For example have 2 actions:
addProductToCart
,refreshCart
. Each of they callstartLoading(dispatcher, 'cart')
on method enter andendLoading(dispatcher, 'cart')
before each return. The problem occurs whenaddProductToCart
callsrefreshCart
inside. End loading occurs too early.It is similar to nested transactions.