Dagger 2 - how to create/provide a EagerSingleton
问题 I am having trouble with the Dagger 2 dependency injection framework. I would like to create an EagerSingleton . I assume that dagger 2 creates lazy loaded singletons when I use the @Singleton annotation. How do I create EagerSingleton using the Dagger 2 framework ? 回答1: I solved this by creating an EagerModule which had a single provide method which returned Void . Everything I wanted created eagerly I specified as parameters to that method. Then I added a Void init() method to the Component