Hi all, what's the best approach for a long-runnin...
# coroutines
s
Hi all, what's the best approach for a long-running coroutine with multiple "receivers" ... let's say I have a coroutine which calculates some complex value or fetches something via network. I have multiple locations that might call this coroutine. But instead of starting this coroutine n times it should only run once an deliver the value to all receivers. Is a ConflatedBroadcastChannel here the best architectural choice? So putting the value into the channel so that everyone can take it when needed?
v
try
broadcast
builder, it’s builtin coroutine + channel
b
if you only have a single value, you could use a
CompletableDeferred
s
Thank you guys. The value might be updated multiple times so I will have a look at
broadcast
. However I will keep
CompletableDeferred
in mind for possible future needs 🙂