Timing judgment of asynchronously obtaining back-end data

the value of a variable is assigned through a function that gets back-end data asynchronously. How to deal with the logic related to this variable as soon as it has a value? How to judge the timing?
one way is to use a timer to determine the interval time. Is there any other way?

Mar.25,2021

Asynchronous acquisition must have a callback function. Can't you just handle it in the callback function


deal with it in callback


you can use Promise

Menu