<@U4Z0P340Y> Do you have any plans to add somethin...
# kotlin-inject
d
@evant Do you have any plans to add something like Dagger's
fun inject(someActivity: SomeActivity)
...? It's SO MUCH nicer than having to do the trick in the Android docs on kotlin-inject's Github repo...
e
No plans to add field or function injection. It can leave objects in a partially constructed state which can cause runtime issues if you aren't careful. Pulling your logic out of your activity also makes it easier to test.
d
What difference is it from:
Copy code
class MyActivity : Activity() {
    private lateinit var myScreen: MyScreen

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate()
        myScreen = ActivityComponent::class.create(ApplicationComponent.getInstance(this)).myScreen
e
All the important bits are in MyScreen which you can easily construct and unit test
d
I was really considering to use kotlin-inject instead of Hilt for a bigger module in our app... but I have a bunch of workmanagers that need to be injected with multiple deps, and that could get a bit messy. That separation I do already in what I'm injecting... but I need to manually give all those to each workmanager... which is a lot of boilerplate...
e
https://developer.android.com/reference/androidx/work/WorkerFactory ? Could do the same thing that's suggested for fragments
Working on a generator for the fragment boilerplate actually, could do the same thing for workers https://github.com/evant/kotlin-inject-android
p
@evant it says kotlin-injeft
e
Lol
Fixed