how to execute Synchronize among multiple async function blocks?
example: how do the following two async function blocks proceed sequentially?
class Example {
first;
second;
constructor(){
}
async getFirstVal(){
this.first = await [promise]
}
async getSecondVal(){
this.second = await[firstpromise]
}
async getOtherVal(){
this.other = await[promise]
}
doSomeWork(){
this.getFirstVal();
this.getSecondVal();
this.getOtherVal();
........
}
}
excuse me, what can I do to ensure that the two asynchronous blocks in doSomeWork, first and second , are executed sequentially?
I don"t want to write the logic of this part of second to the getFirstVal method, although this will get the correct execution order, because getFirstVal may be called asynchronously in many places, and I want to encapsulate it as a separate function. Is there any good way to help me implement the sequential execution between async blocks?