Is it a good idea to use SharedViewModel (with Flow inside it) between a ForegroundService and a UI Component (Fragment/ Composables)

20 views Asked by At

I am working on a solution where a ForegroundService will collect information, and that information will be displayed in a screen (Composable).

I gone through the documentation here. I would like to know using SharedViewModel is a good approach or not.

Is it good approach to use SharedViewModel (injected via Koin) in both Foreground service and also in Composable, and then SharedViewModel will publish the collected information to the flow in the SharedViewModel, and the same will be consumed by the Fragment/Composable.

Note: There is no much documentation / answers related to this question here.

0

There are 0 answers