Paul Woitaschek
10/08/2019, 8:15 AMPublishSubject
alternative as flow. The closest representation I found is a Channel(RENDEZVOUS)
. However the consumeAsFlow
function states:
If the flow consumer fails with an exception, channel is cancelled.I don't want that. Is there an alternative for that?
louiscad
10/08/2019, 9:37 AMPaul Woitaschek
10/08/2019, 9:38 AMlouiscad
10/08/2019, 9:47 AMBroadcastChannel
(or the broadcast
operator I think). Beware of not leaking hot resources!Luis Munoz
10/08/2019, 3:53 PMPaul Woitaschek
10/08/2019, 4:16 PMclass ViewModel {
private val _events = Channel<Event>(RENDEZVOUS)
val events : Flow<Event> get() = _events.consumeAsFlow()
}
_events
channel to close permanently because a consumer threw an exception in it’s collect function.
So now there is this implicit contract: Don’t throw an exception or the channel is broken and there will be no more eventsLuis Munoz
10/08/2019, 4:46 PMPaul Woitaschek
10/08/2019, 9:03 PMelizarov
10/08/2019, 9:25 PMPaul Woitaschek
10/09/2019, 4:55 AM