We need to be able to inject classes into the new Worker class from WorkManager API's. This will be useful if we need to inject NetworkRepo's or LocalDbRepo's etc..
Target Koin project
https://github.com/sriramr98/Wally
Hi @sriramr98 , I'll check that 馃憤
You can access applicationContext from Worker, isn't it enough?
@sockeqwe How do you inject a class using the applicationContext ?
You can make your Worker class implement KoinComponent interface
then simply in doWork() you can call
override fun doWork(): Result {
val networkRepo: NetworkRepo by inject()
...
}
Thanks, @stasbar. Works perfectly
You can make your
Workerclass implementKoinComponentinterface
then simply indoWork()you can calloverride fun doWork(): Result { val networkRepo: NetworkRepo by inject() ... }
nice works perfectly as well!!!
Most helpful comment
You can make your
Workerclass implementKoinComponentinterfacethen simply in
doWork()you can call