Dagger 2 – what is the purpose of a @Singleton annotation class

@Singleton (and any other scope annotation) makes your class a single instance in your dependencies graph (it means that this instance will be “singleton” as long as Component object exists).

In short – everytime you’re injecting @Singleton annotated class (with @Inject annotation) it will be the same instance as long as you inject it from the same Component.

For more I’m referring my blog post about how @Singleton and other scopes annotations works in Dagger 2: http://frogermcs.github.io/dependency-injection-with-dagger-2-custom-scopes/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)