-
Notifications
You must be signed in to change notification settings - Fork 7.6k
2.x Design: Flowable/Observable #3348
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
Conversation
Proposed separation of `Observable` and `Flowable` along with description of each and their characteristics.
Related to discussion in #2787 (comment) |
|
||
Flow control support: | ||
|
||
- buffering, sampling, throttling, windowing, dropping, etc |
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.
Note that sampling by itself still can overflow a client if said client doesn't request fast enough or big enough. Same is true for throttling and non-count based buffering (such as with boundary Publisher). Window is a bit both since the outer sequence may overflow the client but the inners can't because UnicastSubject buffers values (see subscription gap problem) and replays them with as the client requests.
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.
Yep, but they are still approaches to flow control.
@ReactiveX/rxjava-committers Is there agreement to support If there are questions needing answering before you can respond, please ask the questions now so we can move forward. I have posted lengthy explanations of reasoning here: Another example supporting the need of the two types is that |
Here are some ideas on API design and comparisons between the types: PushObservable.create(s -> {
s.onNext(t)
...
s.onNext(t)
}) would be equivalent to this if we chose to have these APIs: Flowable.createPush(s -> {
s.onNext(t)
...
s.onNext(t)
}, BackpressureStrategy.BUFFER) Pull-Push/Async PullObservable does not support pull. With Flowable there is synchronous variety: Flowable.createSync(... SyncOnSubscribe ... )
// or
Flowable.from(Iterable)
// or
Flowable.just(T...)
// or
Flowable.range(0, 10000000) and an asynchronous variety: Flowable.createAsync(... AsyncOnSubscribe ... ) ConversionFrom Flowable f = ...
Observable<T> o = f.toObservable(); // this will call request(Long.MAX_VALUE) up when subscribed to From Observable o = ...
Flowable<T> f = o.toFlowable(BackpressureStrategy.*)
// for example
Flowable<T> f = o.toFlowable(BackpressureStrategy.BUFFER)
// or
Flowable<T> f = o.toFlowable(BackpressureStrategy.DROP)
// or
Flowable<T> f = o.toFlowable(BackpressureStrategy.FAIL)
// or
Flowable<T> f = o.toFlowable(BackpressureStrategy.create(...)) // like lifting an operator into a stream, except for a backpressure strategy |
I think instead of I don't particulary like the name swap because users now have learned about the Observable being the one where one doesn't have to worry about memory overflow so much. The change, I think, will create a lot of confusion. I don't particularly understand the need for this non-backpressure version again (even though I was skeptical about the addition of backpressure back then). Is it the overhead of the backpressure management? Is it the latency caused by the scattering effect when crossing a thread boundary? Or is it that one wants to manually emit onNext event "mindlessly"? |
This doesn't make sense to me, since
The rest of the ReactiveX community argues the opposite that RxJava has caused confusion by adding backpressure to The argument also is that adding backpressure has made usage of
From 0.20 to 1.0 it evolved. The community dealt with it. Now I hear that combining the two has confused people. Separating the types is intended to clarify. And to stop confusing when compared against RxJS, Rx.Net, etc.
The issue with Additionally, there is overhead as you mention, though honestly, this is rarely applicable to most use cases.
This is the key, but "mindlessly" is dismissive. All "hot", push, use cases are like this. I can easily argue that Flowable.createPush(s -> {
s.onNext(t)
...
s.onNext(t)
}, BackpressureStrategy.BUFFER) But the type itself does nothing to communicate that this is push. Today, the default v1 Flowable.createPush(s -> {
s.onNext(t)
...
s.onNext(t)
}, BackpressureStrategy.FAIL) I think that has confused people. My conclusion of this debate is that it is actually quite subjective, but that alignment with the broader ReactiveX community is worth separating the types so that |
Fine. |
To be precise, I'm not against having Single, Observable and Flowable in the library and if the community can deal with name- and feature-"shuffle" then I accept the decision.
In greater detail, I proposed that instead of having
The drawback is the lack of compile-time validation of strategyParams. |
An Sorry for not being clear on Flowable<T> f = o.toFlowable(BackpressureStrategy.create(...)) // like lifting an operator into a stream, except for a backpressure strategy |
Despite the debate over API design (which we can continue later), should we merge this PR? |
The text is okay 👍 |
Thanks @akarnokd Anyone else have opinions on this? Reasons to not proceed? |
The name shuffle is a thumbs down from me just for the loss of continuity On 18 September 2015 at 06:42, Ben Christensen [email protected]
|
I supported the initial change and still support it now. The text is fine by me 👍 |
Flow is the interface name in Java 9. Hence
The only thing that would not apply to the new The loss of continuity and alignment with the broader ReactiveX community is equally bad, just look at polyglot docs at reactivex.io to see how the RxJava |
Thank you @tilal6991 for your review and weighing in. |
I would support a type called |
I'm okay with us exploring that type of thing. However, let's figure out the design contract of the core types first. |
Anyone else have 👍 or 👎 on this before I proceed to merge it? |
👍 |
Merging so we can move forward on Design.md. |
2.x Design: Flowable/Observable
Proposed separation of
Observable
andFlowable
along with description of each and their characteristics.