Is it more idiomatic Scala to pass in ExecutionContext
per method like
class Foo {
def bar(a: Int, b: Int)(implicit ec: ExecutionContext): Future[Int] = {
Future(a + b)
}
def baz(a: Int, b: Int)(implicit ec: ExecutionContext): Future[Int] = {
Future(a - b)
}
}
or better to pass in ExecutionContext
per class like
class Foo(implicit ec: ExecutionContext) {
def bar(a: Int, b: Int): Future[Int] = {
Future(a + b)
}
def baz(a: Int, b: Int): Future[Int] = {
Future(a - b)
}
}
Is one style usually more preferred in Scala world because it causes less surprises, is easier to read, or for other reasons? Please give some references if possible.