I have a Dagger2 @Module
class with the @Provides
annotated method which calls Retrofit.create
method:
@Provides
RestService provideRestService(final Retrofit retrofit) {
return retrofit.create(RestService.class);
}
Should I annotate this method with the @Singleton
annotation?
I see one reason to do it: calling create
each time has some cost and one reason for not doing it: keeping one instance has some cost (Dagger performs double checking each time instance is requested).
Which solution is preferred? With or without @Singleton
annotation? Or maybe it is not important at all? Or my approach to create this class in provider is fundamentally wrong?