diesieben07
01/09/2020, 9:43 AMFlow.asObservable
it just dumps the flow into the emitter as fast it can, without regard for the backpressure mechanisms 😞 (https://github.com/Kotlin/kotlinx.coroutines/blob/master/reactive/kotlinx-coroutines-rx2/src/RxConvert.kt#L80-L107). The opposite (convert Observable into ReceiveChannel) does the same: https://github.com/Kotlin/kotlinx.coroutines/blob/master/reactive/kotlinx-coroutines-rx2/src/RxChannel.kt#L65-L96SubscriptionChannel
) as a basis, but even that I can't do, because there are no channel implementations in the coroutines library that are subclassable (it's all internal). You have to always implement everything from scratch... is this by design? If so, why?Adam Powell
01/09/2020, 9:38 PMdiesieben07
01/09/2020, 9:43 PMobservable doesn't do backpressureHuh? https://github.com/ReactiveX/RxJava/wiki/Backpressure
https://github.com/Kotlin/kotlinx.coroutines/blob/master/reactive/kotlinx-coroutines-reactive/src/ReactiveFlow.kt might be a more useful exampleA
Flow
is not what I want. The context is gRPC, so a remote procedure call. It has to be predictable when and how often it happens. I don't want the call to happen twice if you accidentally consume the flow twice. That is why I specifically want a Channel
, which can only be consumed once.Zach Klippenstein (he/him) [MOD]
01/09/2020, 10:34 PMFlowable
because Observable
doesn’t have backpressure.
But you’re talking about sharing, which is a separate issue from backpressure?diesieben07
01/09/2020, 10:35 PMObservable
in RxJava not have backpressure? I am not a user of RxJava, but reading the above link it seems it very much has (by calling request
if you want more items).Zach Klippenstein (he/him) [MOD]
01/09/2020, 10:37 PMObservable
does have backpressure, but in Rx2 there are two parallel types, Flowable
and Observable
, and the only difference is Flowable
has backpressure and Observable
does not.diesieben07
01/09/2020, 10:38 PMZach Klippenstein (he/him) [MOD]
01/09/2020, 10:39 PMObservable
one, but you’ll notice request tracking and stuffPublisher
is the generic “reactive streams” version of RxJava’s Flowable
, and Flowable
actually implements the Publisher
interface)diesieben07
01/09/2020, 10:41 PMZach Klippenstein (he/him) [MOD]
01/09/2020, 10:42 PMdiesieben07
01/09/2020, 10:42 PMZach Klippenstein (he/him) [MOD]
01/09/2020, 10:44 PMdiesieben07
01/09/2020, 10:47 PMZach Klippenstein (he/him) [MOD]
01/09/2020, 10:58 PM