-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Singleton and LazySingleton support #187
Comments
Can you be more specific on what you are looking for? You can already inject |
I must be missing the point of the scopes in that case. I was looking for something like: @LazySingleton
@Inject
class UserRepository internal constructor(
private val userApi: UserApi,
)``` |
Scopes live as long as their component, so you can do this by having a single top-level component. @Scope
annotation class Singleton
@Singleton
@Inject
class UserRepository
@Singleton
@Component
abstract class SingletonComponent {
abstract val userRepo: UserRepository
companion object {
val Instance = SingletonComponent::class.create()
}
} |
And scoped dependencies are instantiated when they are first accessed so I guess they are all lazy? |
I'll take a look, thanks! |
It would be great if we could have singletons and lazy singleton support
The text was updated successfully, but these errors were encountered: