I have written something like;
self.handleAction = async function (event) {
$("#someDivID").show();
await __method1();
//log something
await __method2();
$("#someDivID").hide();
}
The thing is, I know the __method1()
and __method2()
will take time to execute and hence I'm using the async-await
approach here.
The JQuery show
and hide
methods are supposed to show a certain div while the processing is happening (kind of like a loading gif.) I'm using the same code in other flows in the code and it works fine.
Observation;
- The code does nothing seemingly asynchronously.
- The JQuery approach to show and hide a certain element at the start and end of the function is never seen.
Questions;
- Is the expectation to have the
__method1
and__method2
run asynchronously in such a code structure incorrect? What am I missing? - Why would the
show()
andhide()
methods not be working as expected here?
P.S - In other areas where similar async-await
and the show-hide
approach is being used, I have fetch()
calls and promises in the picture.
This method event however is pure computation and no fetch API's are involved.