I am using Anvil and I have a class with no arg co...
# squarelibraries
I am using Anvil and I have a class with no arg constructor and which doesnt extend any interface and I'm tempted to add it with
, but this requires that target class extends some interface. Is it wrong to wish this? It just looks simpler than writing a boring provide with
in the Module.
You don't need to create a provide method. Just add an
annotation to your empty constructor.
Copy code
class MyClass @Inject constructor() {}
awesome. I faintly remembered something like this could work, but wasn't sure. It has been quite some time since I last used Dagger 🙂
👍 1
That sample doesn’t work. You can only use
for Dagger modules and component interfaces, but not classes with an
If you don’t have any super types, then you don’t need Anvil at all. You can simply inject the type with the
constructor. Nothing else is needed.
👌 1
Thanks @ralf I removed the wrong annotation, that's what I get for writing sudo code on my phone after just waking up 😅