I would like to ask if it's possible to 'return' a value from a function if the function doing AsyncTask?
For example :
fun readData() : Int{
val num = 1;
doAsync {
for (item in 1..1000000){
num += 1;
}
}
return num;
}
The problem in this function is that the AsyncTask is not finish yet so i get a wrong value from the function ,any idea how to solve it?
is using a interface is the only why or there is a compilation handler like in Swift ?