@@ -12,17 +12,20 @@ export const getCounter = area => counter[area];
1212
1313export const trackPromise = ( promise , area ) => {
1414 area = area || defaultArea ;
15- incrementCounter ( area ) ;
16-
17- const promiseInProgress = anyPromiseInProgress ( area ) ;
18- emitter . emit ( promiseCounterUpdateEventId , promiseInProgress , area ) ;
15+ incrementPromiseCounter ( area ) ;
1916
2017 const onResolveHandler = ( ) => decrementPromiseCounter ( area ) ;
2118 promise . then ( onResolveHandler , onResolveHandler ) ;
2219
2320 return promise ;
2421} ;
2522
23+ const incrementPromiseCounter = area => {
24+ incrementCounter ( area ) ;
25+ const promiseInProgress = anyPromiseInProgress ( area ) ;
26+ emitter . emit ( promiseCounterUpdateEventId , promiseInProgress , area ) ;
27+ } ;
28+
2629const incrementCounter = area => {
2730 if ( Boolean ( counter [ area ] ) ) {
2831 counter [ area ] ++ ;
@@ -56,11 +59,7 @@ export const manuallyDecrementPromiseCounter = area => {
5659
5760export const manuallyIncrementPromiseCounter = area => {
5861 area = area || defaultArea ;
59- incrementCounter ( area ) ;
60-
61- const promiseInProgress = anyPromiseInProgress ( area ) ;
62- emitter . emit ( promiseCounterUpdateEventId , promiseInProgress , area ) ;
62+ incrementPromiseCounter ( area ) ;
6363} ;
64-
6564// TODO: Enhancement we could catch here errors and throw an Event in case there's an HTTP Error
6665// then the consumer of this event can be listening and decide what to to in case of error
0 commit comments