. I presume it's about backpressure right? If so, to mimic rxjava Observable, I want
trySendBlocking
right?
l
louiscad
06/15/2021, 6:38 AM
Did you read their respective KDoc? I think it's all explained there.
👎 1
e
elizarov
06/16/2021, 7:44 AM
If want to drop extra element on backpressue, you do
trySend
, to block in case of backpressue ->
trySendBlocking
👍 1
u
ursus
06/16/2021, 9:43 AM
If I might ask, does the backpressure sort of happen right away or are there some internal buffers?
From rxjava I faintly remember that yes Observable doesnt support backpressure, i.e. blocks caller, however I do remember there being some 64 sized buffer in it or something like that, so it should not happen that often
e
elizarov
06/16/2021, 9:44 AM
Default is 64, you can configure with
buffer(n)
u
ursus
06/16/2021, 9:47 AM
so callbackflow with trySendBlocking behaves exactly as rxjava.. now I need to figure out why IDE warns me about Inapropriate blocking call when using it 😀
l
louiscad
06/16/2021, 9:54 AM
Because it can block, and that might not be what you want.
Using
conflate()
or properly configured
buffer(…)
along with
trySend(…)
is often a better solution (but it depends on use case and requirements).
u
ursus
06/17/2021, 8:31 AM
why does the method exist then
l
louiscad
06/17/2021, 11:28 AM
I guess there are use cases for it that I'm not aware of.