CoroutineBinding icon indicating copy to clipboard operation
CoroutineBinding copied to clipboard

Offer for Channel can cause dropped elements

Open eygraber opened this issue 5 years ago • 2 comments

I've been using TextView.textChanges and there's an issue with using safeOffer and capacity = RENDEZVOUS. If the consumer suspends before receiving again (e.g. calls delay for whatever reason), and elements are offered during this time (i.e. more text is typed), offer will fail, and those elements will never get sent/received.

It's not immediately obvious that capacity = RENDEZVOUS is the default, and that safeOffer causes the problem. The solution would be to call send in a launch (either from the GlobalScope or pass a CoroutineScope in).

eygraber avatar Jul 23 '19 22:07 eygraber

Sorry too late response.

I plan that replace ReceiveChannel API with Flow. Flow API(+ buffer or broadcastIn) to the rescue this issue.

satoshun avatar Jul 29 '19 00:07 satoshun

https://github.com/ReactiveCircus/FlowBinding

afollestad avatar Jan 17 '20 22:01 afollestad