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 concatMapCompletable() to Observable #5649

Merged
merged 8 commits into from
Oct 9, 2017

Conversation

dweebo
Copy link
Contributor

@dweebo dweebo commented Oct 6, 2017

Add concatMapCompletable() to Observable as discussed in #4853
I didn't think it made sense in other reactive types.

Code is mostly a copy of ObservableConcatMap. Let me know if there is a better style of code to base this off instead. It also does not have the option to delay errors as concatMap() does, not sure if that is needed.

@codecov
Copy link

codecov bot commented Oct 6, 2017

Codecov Report

Merging #5649 into 2.x will decrease coverage by 0.04%.
The diff coverage is 96.46%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5649      +/-   ##
============================================
- Coverage     96.19%   96.15%   -0.05%     
- Complexity     5843     5849       +6     
============================================
  Files           634      635       +1     
  Lines         41539    41652     +113     
  Branches       5752     5768      +16     
============================================
+ Hits          39960    40050      +90     
- Misses          626      640      +14     
- Partials        953      962       +9
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Observable.java 100% <100%> (ø) 508 <2> (+2) ⬆️
...ors/observable/ObservableConcatMapCompletable.java 96.33% <96.33%> (ø) 2 <2> (?)
...nternal/operators/observable/ObservableCreate.java 79.48% <0%> (-15.39%) 2% <0%> (ø)
.../io/reactivex/internal/functions/ObjectHelper.java 94.73% <0%> (-5.27%) 20% <0%> (-1%)
...ava/io/reactivex/processors/BehaviorProcessor.java 88.49% <0%> (-4.87%) 62% <0%> (ø)
...l/operators/observable/ObservableFlatMapMaybe.java 84.96% <0%> (-4.58%) 2% <0%> (ø)
.../internal/operators/flowable/FlowableInterval.java 94.44% <0%> (-2.78%) 3% <0%> (ø)
...vex/internal/operators/flowable/FlowableCache.java 92.61% <0%> (-2.69%) 7% <0%> (ø)
...tivex/internal/schedulers/TrampolineScheduler.java 92.3% <0%> (-2.57%) 6% <0%> (ø)
...rnal/operators/flowable/FlowableIntervalRange.java 95.91% <0%> (-2.05%) 3% <0%> (ø)
... and 32 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 748fb50...783aab2. Read the comment docs.

* @param mapper
* a function that, when applied to an item emitted by the source ObservableSource, returns a CompletableSource
* @return a Completable that signals {@code onComplete} when the upstream and all CompletableSources complete
*/
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 @since 2.1.6 - experimental

*/
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Completable concatMapCompletable(Function<? super T, ? extends CompletableSource> mapper) {
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 @Experimental.

* @param prefetch
* the number of elements to prefetch from the current Observable
* @return a Completable that signals {@code onComplete} when the upstream and all CompletableSources complete
*/
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 @since 2.1.6.

*/
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Completable concatMapCompletable(Function<? super T, ? extends CompletableSource> mapper, int prefetch) {
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 @Experimental.

*
* @param mapper
* a function that, when applied to an item emitted by the source ObservableSource, returns a CompletableSource
* @param prefetch
Copy link
Member

Choose a reason for hiding this comment

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

A capacityHint would capture the underlying behavior better: "the number of upstream items expected to be buffered until the current CompletableSource, mapped from the current item, completes."

Copy link
Member

@akarnokd akarnokd left a comment

Choose a reason for hiding this comment

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

Codewise it looks okay. /cc @artem-zinnatullin, @vanniktech & @davidmoten who was also interested in this.

Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

Should we also include a diagram?

@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Completable concatMapCompletable(Function<? super T, ? extends CompletableSource> mapper) {
return concatMapCompletable(mapper, 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not we pass 8 here since it'll get overridden to 8 in the implementation?

Copy link
Member

Choose a reason for hiding this comment

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

Leave it for now.

@akarnokd
Copy link
Member

akarnokd commented Oct 9, 2017

Added to #5319 for the diagram.

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