Futures and Async Concepts
Then Transform
Transform a ready value in ordered steps.
Then Transform
ThenTransform.scala
object Main {
def main(args: Array[String]): Unit = {
val fetched =
val plusOne = fetched + 1
val doubled = plusOne * 2
val label = "ready:" + doubled
println("fetched=" + fetched)
println("plusOne=" + plusOne)
println("doubled=" + doubled)
println("label=" + label)
}
}
object Main {
def main(args: Array[String]): Unit = {
val fetched =
val plusOne = fetched + 1
val doubled = plusOne * 2
val label = "ready:" + doubled
println("fetched=" + fetched)
println("plusOne=" + plusOne)
println("doubled=" + doubled)
println("label=" + label)
}
}
object Main {
def main(args: Array[String]): Unit = {
val fetched =
val plusOne = fetched + 1
val doubled = plusOne * 2
val label = "ready:" + doubled
println("fetched=" + fetched)
println("plusOne=" + plusOne)
println("doubled=" + doubled)
println("label=" + label)
}
}
then-transform
Future-style `map` or `then` logic takes a ready value and computes the next value. Sequential scalar assignments make the transformation visible.