Skip to content

Instantly share code, notes, and snippets.

@chenharryhua
Created February 9, 2017 00:31
Show Gist options
  • Save chenharryhua/9ede05d8fdf3b26984e07e762f65129e to your computer and use it in GitHub Desktop.
Save chenharryhua/9ede05d8fdf3b26984e07e762f65129e to your computer and use it in GitHub Desktop.
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
object ImplicitInjection {
final class Foo(implicit ec: ExecutionContext){
def foo = Future(1).map(_ + 1)
}
trait Bar {
implicit val ec : ExecutionContext
def bar = Future(1).map(_ + 1)
}
object Baz {
def baz(implicit ec: ExecutionContext) = Future(1).map(_ + 1)
}
}
@chenharryhua
Copy link
Author

three ways to bring ExecutionContext into scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment