You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently pommel only works on classes that have a constructor annotated with @Inject. This works if you own the class and mark the constructor with @Inject but there are cases where you don't own the class and want to provide an instance of said class in your dagger graph.
Let's say I'm building an Android application that connects to a REST API and I want to have the base url for my service on the dagger graph. You would normally do something like this
@Module
object ServiceModule {
@Provides
@Named("baseUrl")
funprovidesBaseUrl(): String="https:://api.service.com"... // more service module configuration
}
If I wanted to replace baseUrl in testing I would have to create a module with just the baseUrl binding. Pommel should provide a way to annotate a field to generate the module for these types of bindings. Maybe something like the following
@SoloModule
@Named("baseUrl")
val baseUrl:String="https:://api.service.com"
We can perhaps repurpose the @SoloModule annotation to work on both a class and a field or possibly create a new annotation that works only on fields, Maybe @SoloField?
The text was updated successfully, but these errors were encountered:
Currently pommel only works on
class
es that have aconstructor
annotated with@Inject
. This works if you own theclass
and mark theconstructor
with@Inject
but there are cases where you don't own theclass
and want to provide an instance of saidclass
in your dagger graph.Let's say I'm building an Android application that connects to a REST API and I want to have the base url for my service on the dagger graph. You would normally do something like this
If I wanted to replace
baseUrl
in testing I would have to create a module with just the baseUrl binding. Pommel should provide a way to annotate a field to generate the module for these types of bindings. Maybe something like the followingwould generate the equivalent of:
We can perhaps repurpose the
@SoloModule
annotation to work on both aclass
and afield
or possibly create a new annotation that works only on fields, Maybe@SoloField
?The text was updated successfully, but these errors were encountered: