From 1f8c2b3182217a8c0180f1f9e975c1d0385d67d3 Mon Sep 17 00:00:00 2001 From: Luka Cindro Date: Fri, 19 Feb 2016 14:42:02 +0100 Subject: [PATCH] Add maxConcurrent overload to flatMapIterable --- src/main/java/rx/Observable.java | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/main/java/rx/Observable.java b/src/main/java/rx/Observable.java index 5e42dc830c..e8b139213c 100644 --- a/src/main/java/rx/Observable.java +++ b/src/main/java/rx/Observable.java @@ -5558,6 +5558,36 @@ public final Observable flatMapIterable(Func1 + * + *
+ *
Scheduler:
+ *
{@code flatMapIterable} does not operate by default on a particular {@link Scheduler}.
+ *
+ * + * @param + * the type of item emitted by the resulting Observable + * @param collectionSelector + * a function that returns an Iterable sequence of values for when given an item emitted by the + * source Observable + * @param maxConcurrent + * the maximum number of Observables that may be subscribed to concurrently + * @return an Observable that emits the results of merging the items emitted by the source Observable with + * the values in the Iterables corresponding to those items, as generated by {@code collectionSelector} + * @throws IllegalArgumentException + * if {@code maxConcurrent} is less than or equal to 0 + * @see ReactiveX operators documentation: FlatMap + * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) + */ + @Beta + public final Observable flatMapIterable(Func1> collectionSelector, int maxConcurrent) { + return merge(map(OperatorMapPair.convertSelector(collectionSelector)), maxConcurrent); + } + /** * Returns an Observable that emits the results of applying a function to the pair of values from the source * Observable and an Iterable corresponding to that item that is generated by a selector. @@ -5587,6 +5617,42 @@ public final Observable flatMapIterable(Func1 + * + *
+ *
Scheduler:
+ *
{@code flatMapIterable} does not operate by default on a particular {@link Scheduler}.
+ *
+ * + * @param + * the collection element type + * @param + * the type of item emited by the resulting Observable + * @param collectionSelector + * a function that returns an Iterable sequence of values for each item emitted by the source + * Observable + * @param resultSelector + * a function that returns an item based on the item emitted by the source Observable and the + * Iterable returned for that item by the {@code collectionSelector} + * @param maxConcurrent + * the maximum number of Observables that may be subscribed to concurrently + * @return an Observable that emits the items returned by {@code resultSelector} for each item in the source + * Observable + * @throws IllegalArgumentException + * if {@code maxConcurrent} is less than or equal to 0 + * @see ReactiveX operators documentation: FlatMap + * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) + */ + @Beta + public final Observable flatMapIterable(Func1> collectionSelector, + Func2 resultSelector, int maxConcurrent) { + return flatMap(OperatorMapPair.convertSelector(collectionSelector), resultSelector, maxConcurrent); + } + /** * Subscribes to the {@link Observable} and receives notifications for each element. *