-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Single.flatMapPublisher full implementation #6021
2.x: Single.flatMapPublisher full implementation #6021
Conversation
Codecov Report
@@ Coverage Diff @@
## 2.x #6021 +/- ##
============================================
+ Coverage 98.29% 98.29% +<.01%
- Complexity 6163 6166 +3
============================================
Files 659 660 +1
Lines 44521 44557 +36
Branches 6201 6201
============================================
+ Hits 43760 43799 +39
- Misses 226 228 +2
+ Partials 535 530 -5
Continue to review full report at Codecov.
|
import io.reactivex.internal.functions.ObjectHelper; | ||
import io.reactivex.internal.subscriptions.SubscriptionHelper; | ||
|
||
public final class SingleFlatMapPublisher<S, T> extends Flowable<T> { |
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.
Please add a JavaDoc here (you can copy the docs from the operator) that includes @since 2.1.15
(no need for experimental). Also it would be great of the type arguments would be T, R
.
} | ||
|
||
static final class SingleFlatMapPublisherObserver<S, T> extends AtomicLong | ||
implements SingleObserver<S>, Subscriber<T>, Subscription { |
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.
Please FlowableSubscriber
, otherwise the safety layer is added as a mapped Flowable
will think it talks to an arbitrary consumer.
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.
Thanks, I'll go and check my other libraries for that one.
|
||
final Subscriber<? super T> actual; | ||
final Function<? super S, ? extends Publisher<? extends T>> mapper; | ||
final AtomicReference<Subscription> parent = new AtomicReference<Subscription>(); |
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.
Nit: initialize in constructor?
public void onSuccess(S value) { | ||
Publisher<? extends T> f; | ||
try { | ||
f = ObjectHelper.requireNonNull(mapper.apply(value), "mapper returns null"); |
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.
Usually it says The mapper returned a null Publisher
.
Publisher<? extends T> f; | ||
try { | ||
f = ObjectHelper.requireNonNull(mapper.apply(value), "mapper returns null"); | ||
} catch (Exception e) { |
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.
Throwable e
6a5c9aa
to
e5244e9
Compare
e5244e9
to
377b6e2
Compare
I've made those changes. |
See discussion in #6015.
Resolves: #6015