https://kotlinlang.org logo
Title
p

Paul Woitaschek

04/13/2019, 2:22 PM
If I need a behaviorsubject in the flow world: is a ConflatedBroadcastChannel and exposing it as asFlow() the way to go? Or is there a better equivalent?
s

streetsofboston

04/13/2019, 3:37 PM
Would this help you for your code? https://github.com/Kotlin/kotlinx.coroutines/issues/1086 This gist is related to that issue: https://gist.github.com/streetsofboston/39c3f8c882c9891b35e0ebc3cd812381 The
fun <T> Flow<T>.cache(scope: CoroutineScope, cacheSize: Int = 1): Flow<T> = replay(cacheSize).autoConnect(scope)
may do what you are looking for.
g

gildor

04/14/2019, 12:43 AM
Yes, there is BroadcadtChannel to flow adapter, it should work fine, just exposing flow instead of receivechannel