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

79
Views
javascript async await for function before continuing

I have a helper function that calls other functions. I want the called functions to finish before continuing on in the helper function.

currently they are both changing things at the same time.

helperDikjstras = async() => {
  //do stuff
  await this.colorVisited(visitedNodes); // I want this function to finish before continuing
  await this.colorPath(path);

  //EDIT: I've also tried:
  this.colorVisited(visitedNodes).then(() => this.colorPath(path));
    return;
  }

  colorVisited = async (visitedNodes) => {
    //do stuff
    return;
  }

  colorPath = async (path) => {
    //do stuff
    return;
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Of course they do, that's the way it works. There is no "interupt" or pause capability in JavaScript. To achieve your goal, call your follow-on functions in the subsequent .then() of the first await.

Like so:

helperDikjstras = async() => {/*...*/}
colorVisited = async(visitedNodes, _callback) => {/*...*/}
colorPath = async(path) => {/*...*/}


helperDikjstras()
  .then(() => colorVisited(blah, halb))
  .then(() => colorPath(somePath));

If you needed to have other functions run after colorPath() you can simply add more...

helperDikjstras()
  .then(() => colorVisited(blah, halb))
  .then(() => colorPath(somePath))
  .then(() => doSomethingElse())
  .then(() => andAnother())
  .then(() => etc());
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!