Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
Hello Charles,
I wanted to show a couple of additional ways of writing
Sleep
First, you can use
util.promisify
on thesetTimeout
method:You can also use a function like this:
Also, one neat thing I like to do is create a generic
retry
function. That way I can use it on any function that returns aPromise
!It would look something like this:
You can even do the same with the time limit feature!
Cheers! 🍻
Really nice Joel,
regarding the sleep/retry one amazing tool to make it even more simple is rxjs :D
learnrxjs.io/learn-rxjs/operators/...
Ahh the under appreciated rxjs. Such an amazing tool!