Skip to content
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

Merged
merged 1 commit into from
May 27, 2018

Conversation

davidmoten
Copy link
Collaborator

@davidmoten davidmoten commented May 26, 2018

See discussion in #6015.

Resolves: #6015

@codecov
Copy link

codecov bot commented May 26, 2018

Codecov Report

Merging #6021 into 2.x will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...ernal/operators/single/SingleFlatMapPublisher.java 100% <100%> (ø) 2 <2> (?)
src/main/java/io/reactivex/Single.java 100% <100%> (ø) 146 <1> (ø) ⬇️
...nternal/operators/parallel/ParallelReduceFull.java 91.08% <0%> (-3.97%) 2% <0%> (ø)
...ternal/operators/observable/ObservablePublish.java 96.46% <0%> (-3.54%) 11% <0%> (ø)
...a/io/reactivex/internal/util/QueueDrainHelper.java 97.22% <0%> (-2.78%) 56% <0%> (-2%)
...perators/single/SingleFlatMapIterableFlowable.java 95.83% <0%> (-2.5%) 2% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 93.71% <0%> (-2.42%) 2% <0%> (ø)
.../io/reactivex/internal/schedulers/IoScheduler.java 89.24% <0%> (-2.16%) 9% <0%> (ø)
...nternal/operators/observable/ObservableWindow.java 98% <0%> (-2%) 3% <0%> (ø)
...ernal/operators/flowable/FlowableFromIterable.java 94.11% <0%> (-1.07%) 5% <0%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d24bfbd...377b6e2. Read the comment docs.

import io.reactivex.internal.functions.ObjectHelper;
import io.reactivex.internal.subscriptions.SubscriptionHelper;

public final class SingleFlatMapPublisher<S, T> extends Flowable<T> {
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Collaborator Author

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>();
Copy link
Member

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");
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwable e

@davidmoten davidmoten force-pushed the single-flat-map-publisher-full branch from 6a5c9aa to e5244e9 Compare May 26, 2018 22:07
@davidmoten davidmoten force-pushed the single-flat-map-publisher-full branch from e5244e9 to 377b6e2 Compare May 26, 2018 22:08
@davidmoten
Copy link
Collaborator Author

I've made those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants