Questions tagged [assisted-inject]

61 questions
26
votes
1 answer

Using @Assisted inject with multiple params of same Type (@Named params)

my problem boils down to using @Assisted with two string arguments to the factory. The problem is that because Guice treats type as the identification mechanism for parameters, both parameters are the same, and I get a configuration error. Some…
Groostav
  • 3,170
  • 1
  • 23
  • 27
25
votes
4 answers

Looking for an example for Dagger assisted injection

From dagger-discuss@: I have a class that gets some dependencies from the object graph, and other dependencies from a caller at runtime. public class ImageDownloader { // Get these dependencies from the injector. private final HttpClient…
user1071136
  • 15,636
  • 4
  • 42
  • 61
18
votes
1 answer

Guice assistedinject already configured

I have an issue with the AssistedInject. I followed the instructions on this link https://github.com/google/guice/wiki/AssistedInject but when I run my application I get an error: ERROR [2015-04-23 14:49:34,701]…
almy
  • 193
  • 1
  • 1
  • 7
10
votes
1 answer

ViewModel constructor should be annotated with @Inject instead of @AssistedInject

I want to provide some dependency at run time to ViewModel using Hilt. I have followed the solution that was directed by d.android.com this. @HiltViewModel public class ViewViewModel extends ViewModel { ... @AssistedFactory public…
Patriotic
  • 2,103
  • 4
  • 26
  • 36
6
votes
1 answer

guice assisted inject + multibinding + generics

I'm trying to combine this 3 features of Guice: inject, multibinding, generics. I create a prototype of production project, so here it is: First, this is a little hierarchy for generics(in production case there is hierarchy of N entities): …
Andrei Koch
  • 898
  • 1
  • 7
  • 23
6
votes
2 answers

How can I make a non-assisted dependency assisted?

Suppose I have a third party class as follows: public class MyObject { @Inject public MyObject(Foo foo, Bar bar) { ... } } Now suppose that I have a factory interface like so: public interface MyObjectFactory { public MyObject build(Bar…
Kelvin Chung
  • 1,327
  • 1
  • 11
  • 23
5
votes
1 answer

Dagger2.10+: Inject ViewModel in Fragment/Activity which has run-time dependencies

For ViewModels which has only compile-time dependencies, I use the ViewModelProvider.Factory from Architecture components like following: class ViewModelFactory @Inject constructor(private val viewModel: Lazy) :…
5
votes
1 answer

scala-guice and assisted injection

I have been using google-guice with the assisted inject mechanism for quite some time now. As i am in scala, and just discover scala-guice, i'm interested in using it as well. However i'm confused as to how to use assisted injection with it. There…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
4
votes
1 answer

Hilt cannot bind interface when using AssistedInject

Our app follows clean architecture so in the domain layer we have an Interface and a use-case like this: interface MyRepository { suspend fun doSomething(): Result } class MyUseCase @Inject constructor(private val repository:…
hosseinAmini
  • 2,184
  • 2
  • 20
  • 46
4
votes
1 answer

error: cannot find symbol @dagger.Module(includes = {InflationInject_ViewModule.class})

I've tried implementing Jake Wharton's AssistedInject with Dagger 2 (https://github.com/square/AssistedInject) in my project. My code is pretty much identical to…
Villa
  • 459
  • 7
  • 17
4
votes
1 answer

How to make Multibinder work with FactoryModuleBuilder and Generics using Guice?

I've read Google guice - multibinding + generics + assistedinject but it doesn't seem to answer my specific scenario. Here's what i have: The interfaces to use with FactoryModuleBuilder public interface IFilterFactory { T…
Crystark
  • 3,693
  • 5
  • 40
  • 61
3
votes
1 answer

Assisted Inject with Dagger/Hilt

Let's say i have an interface named as interfaceA interface InterfaceA {} And it's concrete implementation with Assisted inject class ImplClass @AssistedInject constructor(@Assisted someClass:SomeCLass):InterfaceA { } How would you go about using…
Ritt
  • 3,181
  • 3
  • 22
  • 51
3
votes
1 answer

How does AssistedInject for Dagger 2 work?

The AssitedInject library from Square is actually an annotation processor that generates Dagger 2 modules. Dagger 2 is also an annotation processor. And as I know there is no way to control the order of processors execution. In this example (see…
3
votes
1 answer

Using AssistedInject in Tests

I read several tutorials and manuals but all of them skips the part that I actually need, which is the actual part where you run the stuff. My scenario is as follows. I have a Connection interface: public interface Connection { void open(Selector…
slashms
  • 928
  • 9
  • 26
3
votes
1 answer

Guice inject different instance based on the parent instance annotation

I am using guice framework in my application. I have a scenario where a single class might require multiple instances of same interface C (but for different purposes) as shown in the example. I am trying to resolve this using the annotation facility…
amrk7
  • 1,194
  • 5
  • 13
  • 33
1
2 3 4 5