Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable assisted injection #78

Closed
xerial opened this issue Aug 10, 2017 · 2 comments
Closed

Enable assisted injection #78

xerial opened this issue Aug 10, 2017 · 2 comments

Comments

@xerial
Copy link
Member

xerial commented Aug 10, 2017

Combine dependency injection and user-supplied arguments to build objects:

trait HttpServer {
   val name:String = _
   val server = bind[Server]
                       .onStart(_.start)
                       .onShutdown(_.close)
}

val server1 = session.build[HttpServer](name = "server1")
val server2 = session.build[HttpServer](name = "server2)

Related:
https://github.com/google/guice/wiki/AssistedInject

@xerial
Copy link
Member Author

xerial commented Aug 17, 2017

Maybe we can use SAM type support in Scala 2.12: http://www.scala-lang.org/news/2.12.0/#lambda-syntax-for-sam-types
to embed abstract method

@xerial
Copy link
Member Author

xerial commented Aug 17, 2017

This can be done by using Scala function and implementing SessionHolder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant