OiO.lk Blog Android Is it possible for my Worker to retrieve data inside a ViewModel?
Android

Is it possible for my Worker to retrieve data inside a ViewModel?


I have this situation, basically I have an app that you can save assets with their info and images. But currently the more images you are saving, the longer it takes to save. So I want to change it to call a worker to save the images, so it can continue to save while the user can still use the app.

The problem is, I need to access the data inside the viewModel with the worker, but didn’t find any info on how to do it. I wanna know if it’s possible or I should do it another way.

I know you can pass data to the worker using a Data.Builder, but what I need to pass is a list of bitmaps, and another list of objects.

I am using Hilt to do the dependency injection for my project, with it I was able to do the DI for another worker that uses some repositories, but I was not able to make a dependency injection to provide the viewModel to the worker I’m trying to create.



You need to sign in to view this answers

Exit mobile version