Home > Back-end >  I'm trying to write an asynchronous pathfinding function using async await in javascript
I'm trying to write an asynchronous pathfinding function using async await in javascript

Time:04-17

I'm testing if it works and a function that runs a while loop will block the code even if it is in an asynchronous function that I am awaiting. How do do something like pathfinding without freezing my webpage?

CodePudding user response:

Doing work keeps the main JS event loop busy.

You can't get around that by using promises or the async and await tools. They are tools to manage asynchronous code, they don't make code asynchronous.

A couple of strategies you could employ are:

  • Moving the work off the main event loop and into a Web Worker.
  • Doing the work in chunks with chunk
  • Related