what would be the proper way with kotlin coroutine...
# announcements
p
what would be the proper way with kotlin coroutines to signal events (like wait / notify in java)?
d
Depends, coroutines are more structured, so there are different ways to achieve this. What are you trying to achieve?
p
I have a background process that periodically downloads stuff from the internet but should also be triggerable using an event.
something like DownloadService.triggerDownload()
so a user can manually force a download
d
Are you planning on passing any parameters?
p
no
d
In that case you probably want to use a
MutableSharedFlow
and call
tryEmit
to signal and
collect
to listen.
👍 2
p
ok thanks @Dominaezzz I will check that out
j
@Dominaezzz are there docs for
MutableSharedFlow
? My biggest gripe about coroutines is that there is so much cool stuff that is not surfaced.
d
There's quite a bit of documentation in the API itself.
j
Yes, if you know where/what to look at 🙂
d
On the
SharedFlow
interface itelf.