Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
Is there any simple way to run coroutines in js without using a third-party library?

Trying to do something similar to Babylon.js's https://doc.babylonjs.com/divingDeeper/events/coroutines


    const spawnMeshesCoroutine = function* () {
      spawnTheFirstMesh();
      yield;
      spawnTheSecondMesh();
      yield;
      spawnTheThirdMesh();
    };
    scene.onBeforeRenderObservable.runCoroutineAsync(spawnMeshesCoroutine());

But wondering if there are any simple JS examples to run a simpler coroutine that may handle some expensive tasks in JS without blocking the UI.

An experiment with "expensive tasks": Looking for solutions to enable non-blocking 60fps autosuggest UI for react

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A way to run a function across multiple event loops is:

async function spawnFirstMeshAsync() {
  return spawnFirstMesh();
}

async function spawnSecondMeshAsync() {
  return spawnSecondMesh();
}

async function spawnThirdMeshAsync() {
  return spawnThirdMesh();
}

async function spawnMeshes() {
  await spawnFirstMesh();
  await spawnSecondMesh();
  await spawnThirdMesh();
}

In terms of synchronizing with frames as Babylon.js does, look into requestAnimationFrame.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda