I have a Function that computes two sub-functions like this.
def someFutureMethod1(input: Int): Int = {
input + 1
}
def someFutureMethod2(input: Int): Int = {
input + 12
}
def method1(sx: Int): Future[Int] = Future {
val future: Int = someFutureMethod1(sx)
val future2: Int = someFutureMethod2(future)
future.andThen{
return future
}
future2.andThen{
return future2
}
}
Print(method1(10))
expected result:
11
23
I wanted to return the results as soon as First function calculated, and Update or append to the same result when second function calculated.
The Second function is dependent on the first function.As soon as first function executed successfully It should return the result. and First function result is passed to second function to compute the second function. If second function is computed then return the second function result alone.
Is there anyway to do this .?
Thanks in Advance !!