-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Rx Observable as Flow #1768
[DRAFT] Rx Observable as Flow #1768
Conversation
How this conversion is supposed to deal with back-pressure that rx |
User can select strategy for backpressure with Btw. this |
I'm worried that the default behavior is the same as
It passes. Now, lets use
It fails. Not good. |
Rx itself forces you to pick the strategy at the point of conversion when going from Observable to Flowable. Perhaps the same technique could be employed here. |
@elizarov @JakeWharton But it's true that in this case default buffer size can be confusing especially if user just say Side note about the |
There is a solution for To understand this solution you need to understand how observables manage the situation of fast producer and slow consumer. Rx observable does not have any kind of explicit asynchronous backpressure control, but it has an implicit "backpressure control" via blocking. A slow observable subscriber takes a long time in its You should leverage this mechanism by replacing Moreover, since P.S. Please add the corresponding tests for no loss of events. |
I added another proposal (in last commit above) for opt-in dropping behavior.
I don't see any other simple solution for users (like adding operators on Rx side or Flow side) that would cause this behavior (no blocking and no buffering). One another solution I can think of is to implement another type of |
btw. it's |
Unfortunately Moreover, if we have this problem of UI events, then we'll be having this problem not only in Now, let's discuss the use-case in a bit more detail:
It looks to me that we already have a solution for it -- |
This reverts commit d520395
OK, so I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please squash this PR to a single commit and rebase it onto the latest develop
branch.
atomicfu on disposable is probably needed to make it 100% correct
I'm sorry for adding more complexity to this PR, but more I analyze potential solutions, less confident I become :-) I added a few propositions in last commit: I like the last version because it is more sequential/simple and high-level (relying on Deferred). (I will cleanup, squash and rebase when some solution is accepted) |
All lock-based solutions and all the solutions that wait (via any means) are potentially prone to deadlocks and should not be used. Here we have a good case where you do not need to invent anything new because a sufficiently good solution already exists and is proven to work inside Rx itself. Just use P.S. You cannot use |
I don't think you can actually use |
Cleaned up version PR: |
I'm closing this one, as it is superseded by #1826 |
No description provided.