You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a bug, but a feature request.
I already implemented that feature on my own, but I think would be great to have it in async module.
The native setInterval is not well-suited for async methods and error handling.
I propose a new setIntervalAsync method that would handle async functions, correctly run and stop intervals and correctly handle errors.
Prototype: setInvervalAsync(asyncFunction, delay, onError). Returns clear function.
Behaviour:
Wait that asyncFunction finishes to run the interval.
If function takes 100ms to finishes and delay is 50ms:
0 ms: start fn
100ms: end fn, start interval
150ms: start fn again
250ms: end fn
If asyncFunction throws, call onError callback with the error. Continues the interval and run again asyncFunction after interval.
When clear function is called, returns a Promise that is resolved when current fn execution is finished. Do not run again interval.
I'll create a package for my implementation soon and share it here.
The text was updated successfully, but these errors were encountered:
This is not a bug, but a feature request.
I already implemented that feature on my own, but I think would be great to have it in async module.
The native
setInterval
is not well-suited for async methods and error handling.I propose a new
setIntervalAsync
method that would handle async functions, correctly run and stop intervals and correctly handle errors.Prototype:
setInvervalAsync(asyncFunction, delay, onError)
. Returns clear function.Behaviour:
Wait that
asyncFunction
finishes to run the interval.If function takes 100ms to finishes and delay is 50ms:
0 ms: start fn
100ms: end fn, start interval
150ms: start fn again
250ms: end fn
If asyncFunction throws, call
onError
callback with the error. Continues the interval and run againasyncFunction
after interval.When clear function is called, returns a Promise that is resolved when current fn execution is finished. Do not run again interval.
I'll create a package for my implementation soon and share it here.
The text was updated successfully, but these errors were encountered: