Skip to content

Instantly share code, notes, and snippets.

@tstone
Last active August 29, 2015 14:04
Show Gist options
  • Save tstone/cf8557f88d5894a23587 to your computer and use it in GitHub Desktop.
Save tstone/cf8557f88d5894a23587 to your computer and use it in GitHub Desktop.
class HttpClient {
def GET(url: String)(implicit context: ExecutionContext) = ???
}
class SomeService(http: HttpClient = new HttpClient) {
def getSomething(implicit context: ExecutionContext) = ???
}
class ServiceB {
def foo(arg: String)(implicit context: ExecutionContext) =
someService.getSomething.map(???)
}
// --- VS ---
class HttpClient(implicit context: ExecutionContext){
def GET(url: String)
}
class SomeService {
def getSomething(implicit client: HttpClient) = ???
}
class ServiceB {
def foo(arg: String)(implicit client: HttpClient) =
someService.getSomething.map(???)
}
// --- VS ---
class SomeService {
def getSomething = (client: HttpClient) => ???
}
class ServiceB {
def foo(arg: String) = someSerivce.getSomething.andThen(???)
}
class Controller {
serviceB.foo("asdf")(client)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment