I have a method as shown below:
private async sendToAll(clients) {
for(const client of clients) {
this.send(client, message);
await true; // What should I put here to allow the rest of the application to continue executing?
}
}
This method iterates through a large array and performs a process. I want the rest of the application to run after each iteration of the loop. I assumed simply using 'await' would achieve this, but it doesn't work. Even 'await true' is ineffective.
In Unity C#, coroutines are frequently used for this purpose. By using 'yield return null', an async method pauses its execution, allowing the main thread to cycle through the remaining parts of the app before returning to where it left off in the async method.
How can I implement this behavior in JavaScript?