I have a function with return value of Future[Int]
def func: Future[Int] = {...}
I will periodically check the return value of func until it meet some condition(e.g. return value greater than 10), then I will take use of this return value to create other future value with map/flatmap.
How can I make this work without any synchronous code? which is listed below:
def check: Future[Int] = {
var ret: Int = Await.result(func, Duration.Inf)
while (ret <= 10) {
ret = Await.result(func, Duration.Inf)
}
Future(ret + 100)
}