Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
I'm trying to write an asynchronous pathfinding function using async await in javascript

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?

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

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 ๐‘› triggering the processing of chunk ๐‘›+1 using setTimeout to introduce a delay during which the main event loop can pick up other work that is waiting for it.
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!