ppvi
03/09/2021, 11:54 AMSharedFlow
(but it replays everything to a second observer), Channel(CONFLATED).*receiveAsFlow*
but only one observer gets updates (and we discarded StateFlow
, consumeAsFlow()
, and .broadcast()
/cc @elizarov @Manuel Vivoelizarov
03/10/2021, 9:48 AMppvi
03/10/2021, 10:10 AMelizarov
03/10/2021, 10:13 AMManuel Vivo
03/10/2021, 10:15 AMelizarov
03/10/2021, 10:20 AMManuel Vivo
03/10/2021, 10:23 AMCould the transition logic be fixedWish we could 🙂 With Compose, things get easier as you can easily host state to avoid this. However, with existing Views… things get more complicated 😞 and it’s difficult to come up with a recommendation that fits most use cases
ppvi
03/10/2021, 10:23 AMelizarov
03/10/2021, 10:26 AMChannel(n)
to set the number of notifications that will be always kept even w/o subscribers.
• For views, you do channel.asFlow().shareIn(scope, start = SharingStarted.whileSusbcribed)
. It means that it will start reading from the channel only when there is at least one subscriber, so the first subscriber starts sharing and drains the channel, the second subscriber will not replay anything (we don’t configure replay in sharing operator)elizarov
03/10/2021, 10:29 AMppvi
03/10/2021, 10:42 AMManuel Vivo
03/10/2021, 10:45 AMppvi
03/10/2021, 11:26 AMppvi
03/18/2021, 11:16 AMval _channel = Channel<Int>(capacity = 2, onBufferOverflow = BufferOverflow.DROP_OLDEST)
val exposedFlow: SharedFlow<Int> = _channel
.consumeAsFlow().shareIn(scope, SharingStarted.WhileSubscribed())
(note the consumeAsFlow
) and this works perfectly thankselizarov
03/18/2021, 3:21 PMelizarov
03/18/2021, 3:23 PM