I have a scenario where the program ends before the future call executes when i warp the call to calltoFutureMethod(data) method in map.
So i had replaced it with Await.result but i do not want to use Await as it blocks but can not also do:
calltoFutureMethod(data) map{
result => sendData(newData)
}
as tail recursion does not allow it. Is there any other way without Await and Thred.sleep with tail recursion?
@scala.annotation.tailrec
def sendData(
data: List[String]
): Unit =
data match {
case head::tail =>
val result = for {
p <- calltoFutureMethod(data)
} yield p
val putDataList = Await.result(result, 10.seconds)
sendData(newData)
}
case Nil => ...
}
def callToFutureMethod(data: List[String]) =
{
Future
{
}
}