Hi! What would you use to communicate between in A...
# coroutines
z
Hi! What would you use to communicate between in Android example
ViewModel
and
CoroutineWorker(WorkManager)
. Point is that in viewmodel I can't create worker and vise versa, so they can't communicate directly. Here ViewModel is producing hls chunks (ts files) and worker would upload them when new is created. I can make one
object Repo
which would connect both pieces but I don't know what to use inside, Channels, Flow? In worker I have one suspend function which need to be blocked while not everything is uploaded. Would be glad if someone could help me with that ☺️ Thanks!
k
I’ve never actually used work manager, but from what I understand you’ll want to persist it to a db. Your app and an instance of work manager are two separate processes so communicating between them can’t be done easily with normal constructs like a flow or channel.
z
Wow, nice, that's a great idea with database. Sometimes it's a must to think out of the box :) Thanks
y
The run in the same process, unless you use the work-multiprocess artifact. Since they are in the same process, you can have some in memory repo also that communicates with a channel. But i agree the dB makes it easy.