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: Add Flowable.concatMap{Maybe,Single}{DelayError} operators #5872

Merged
merged 3 commits into from Mar 1, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Mar 1, 2018

This PR adds operators that allow concatenating a mapped sequence of Maybes or Singles, with or without delaying their errors:

  • concatMapMaybe (+1 overload with prefetch)
  • concatMapMaybeDelayError (+2 overloads with error mode and prefetch)
  • concatMapSingle (+1 overload with prefetch)
  • concatMapSingleDelayError (+2 overloads with error mode and prefetch)

They are in the same PR as the Single variant's implementation is practically the Maybe implementation minus the onComplete case.

Their marbles will be updated in a separate PR.

Originally requested in #4853.

@akarnokd akarnokd added this to the 2.2 milestone Mar 1, 2018
@codecov
Copy link

codecov bot commented Mar 1, 2018

Codecov Report

Merging #5872 into 2.x will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5872      +/-   ##
============================================
+ Coverage     96.54%   96.57%   +0.03%     
- Complexity     5862     5885      +23     
============================================
  Files           647      650       +3     
  Lines         42766    43156     +390     
  Branches       5933     5994      +61     
============================================
+ Hits          41289    41679     +390     
- Misses          568      572       +4     
+ Partials        909      905       -4
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Flowable.java 100% <100%> (ø) 553 <12> (+14) ⬆️
...ternal/operators/mixed/FlowableConcatMapMaybe.java 100% <100%> (ø) 2 <2> (?)
...ernal/operators/mixed/FlowableConcatMapSingle.java 100% <100%> (ø) 2 <2> (?)
.../io/reactivex/internal/functions/ObjectHelper.java 94.73% <0%> (-5.27%) 20% <0%> (-1%)
.../internal/operators/flowable/FlowableInterval.java 94.44% <0%> (-2.78%) 3% <0%> (ø)
...tivex/internal/schedulers/TrampolineScheduler.java 92.3% <0%> (-2.57%) 6% <0%> (ø)
...ernal/operators/flowable/FlowableFromIterable.java 94.11% <0%> (-2.14%) 5% <0%> (ø)
...a/io/reactivex/internal/queue/MpscLinkedQueue.java 98.03% <0%> (-1.97%) 17% <0%> (-1%)
...perators/single/SingleFlatMapIterableFlowable.java 96.66% <0%> (-1.67%) 2% <0%> (ø)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
... and 27 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 84004a6...303e77a. Read the comment docs.

@@ -7313,6 +7313,362 @@ public final Completable concatMapCompletableDelayError(Function<? super T, ? ex
return RxJavaPlugins.onAssembly(new FlowableFlattenIterable<T, U>(this, mapper, prefetch));
}

/**
* Maps the upstream intems into {@link MaybeSource}s and subscribes to them one after the
Copy link
Collaborator

Choose a reason for hiding this comment

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

intems -> items

}

/**
* Maps the upstream intems into {@link MaybeSource}s and subscribes to them one after the
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

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

Still reading the code, but here are few small things in javadoc

* <dt><b>Backpressure:</b></dt>
* <dd>The operator expects the upstream to support backpressure and honors
* the backpressure from downstream. If this {@code Flowable} violates the rule, the operator will
* signal a {@code MissingBackpressureException}.</dd>
Copy link
Contributor

Choose a reason for hiding this comment

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

[signal]s

Copy link
Contributor

Choose a reason for hiding this comment

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

Same in all javadocs below

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds fine with me:

"the operator will signal a MissingBackpressureException."

Copy link
Contributor

Choose a reason for hiding this comment

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

wow, sure, my bad, sorry


/**
* Maps the upstream items into {@link SingleSource}s and subscribes to them one after the
* other succeeds or completes, emits their success value if available or terminates immediately if
Copy link
Contributor

Choose a reason for hiding this comment

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

remove "completes"? It's a Single :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same below

Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

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

👍

* @since 2.1.11 - experimental
*/
@Experimental
public final class FlowableConcatMapMaybe<T, R> extends Flowable<R> {
Copy link
Contributor

Choose a reason for hiding this comment

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

// We urgently need a CallMe operator so we could have FlowableCallMeMaybe 😸

import io.reactivex.subjects.MaybeSubject;
import io.reactivex.subscribers.TestSubscriber;

public class FlowableConcatMapMaybeTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

very nice tests

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.

None yet

3 participants