Skip to content

Instantly share code, notes, and snippets.

@StephanSchmidt
Last active October 17, 2017 13:22
Show Gist options
  • Save StephanSchmidt/a53c8897db133b52efda7172d84751e3 to your computer and use it in GitHub Desktop.
Save StephanSchmidt/a53c8897db133b52efda7172d84751e3 to your computer and use it in GitHub Desktop.
Monix Task for
val task1 = Task.fork(Task { Thread.sleep(2000); println("Runnung 1"); 1 + 1 })
val task2 = Task.fork(Task { println("Runnung 2"); 1 + 1 })
println("a")
val t:Task[Int] = for (
r1 <- task1;
r2 <- task2
) yield r1 + r2
println("b")
--- Or
val t:Task[Int] = for (
r <- Task.mapBoth(task1,task2)(_ + _)
) yield r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment