Simple note for running heavy task asynchronously. The image below are the code in real-world I have written recently.
1) Write an async function with try catch, write down a txt file for tracking logs if needed.
2) Use for...of or normal for loop inside that async function.
3) Use await wait (any name here, does not matter) function (return promise implemented with setTimeout. You have to write this function yourself.
4) Never use forEach here, it does not work.
No comments:
Post a Comment