Matthew Laser
01/27/2022, 10:19 PMby viewModel() per the docs, I wind up with the following:
java.lang.ClassCastException: com.myapp.MyService cannot be cast to androidx.lifecycle.ViewModelStoreOwner
Doing by viewModel() inside of Activity and ComponentActivivty works fine. I also tried switching from Service to LifecycleService with no luck. Any help is appreciated! 🙂wbertan
01/27/2022, 10:45 PMKoinComponent to your Service.wbertan
01/27/2022, 10:46 PMMatthew Laser
01/27/2022, 10:47 PMwbertan
01/27/2022, 10:48 PMby inject()
without any problems. Don't think you will be able to use viewModel 🤔 As your Service isn't a View, right? So why you would need that? If any logic you want is inside that ViewModel, I would say to extract into a UseCase and inject in your ViewModel and in your Service.Matthew Laser
01/27/2022, 10:50 PMViewModel as an architecture component doesnt really formally have anything to do with UI that I know of, but is nicely tied to the lifecycle of its ownerMatthew Laser
01/27/2022, 10:51 PMLifecycleService it'd be worth a shotMatthew Laser
01/27/2022, 10:54 PM