https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

vkholyavin

04/05/2021, 3:47 PM
Hello. What is the best solution for replacing SingleLiveEvent with coroutines? Explanation: I have some events. And multiples subscribers for these events. But I need only one time to consume this event in any of the subscribers.
c

Casey Brooks

04/05/2021, 3:53 PM
SharedFlow is probably your best bet
i

Ian Lake

04/05/2021, 4:22 PM
This use case was specifically covered in Roman's blog post on Shared flows and channels (tl/dr: use a Channel and
receiveAsFlow()
): https://elizarov.medium.com/shared-flows-broadcast-channels-899b675e805c#49e3
👍 6
c

Colton Idle

04/05/2021, 4:49 PM
Still mean to follow up on that long thread from Muzei related to flow.
2 Views