Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda