@@ -7201,8 +7201,8 @@ public final Observable<T> rebatchRequests(int n) {
7201
7201
* that does a similar operation on lists.
7202
7202
* <dl>
7203
7203
* <dt><b>Backpressure Support:</b></dt>
7204
- * <dd>This operator does not support backpressure because by intent it will receive all values and reduce
7205
- * them to a single {@code onNext} .</dd>
7204
+ * <dd>The operator honors backpressure of its downstream consumer and consumes the
7205
+ * upstream source in unbounded mode .</dd>
7206
7206
* <dt><b>Scheduler:</b></dt>
7207
7207
* <dd>{@code reduce} does not operate by default on a particular {@link Scheduler}.</dd>
7208
7208
* </dl>
@@ -7238,10 +7238,24 @@ public final Observable<T> reduce(Func2<T, T, T> accumulator) {
7238
7238
* This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate,"
7239
7239
* "compress," or "inject" in other programming contexts. Groovy, for instance, has an {@code inject} method
7240
7240
* that does a similar operation on lists.
7241
+ * <p>
7242
+ * Note that the {@code initialValue} is shared among all subscribers to the resulting Observable
7243
+ * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer
7244
+ * the application of this operator via {@link #defer(Func0)}:
7245
+ * <pre><code>
7246
+ * Observable<T> source = ...
7247
+ * Observable.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item)));
7248
+ *
7249
+ * // alternatively, by using compose to stay fluent
7250
+ *
7251
+ * source.compose(o ->
7252
+ * Observable.defer(() -> o.reduce(new ArrayList<>(), (list, item) -> list.add(item)))
7253
+ * );
7254
+ * </code></pre>
7241
7255
* <dl>
7242
7256
* <dt><b>Backpressure Support:</b></dt>
7243
- * <dd>This operator does not support backpressure because by intent it will receive all values and reduce
7244
- * them to a single {@code onNext} .</dd>
7257
+ * <dd>The operator honors backpressure of its downstream consumer and consumes the
7258
+ * upstream source in unbounded mode .</dd>
7245
7259
* <dt><b>Scheduler:</b></dt>
7246
7260
* <dd>{@code reduce} does not operate by default on a particular {@link Scheduler}.</dd>
7247
7261
* </dl>
@@ -8167,7 +8181,23 @@ public final Observable<T> scan(Func2<T, T, T> accumulator) {
8167
8181
* <p>
8168
8182
* Note that the Observable that results from this method will emit {@code initialValue} as its first
8169
8183
* emitted item.
8184
+ * <p>
8185
+ * Note that the {@code initialValue} is shared among all subscribers to the resulting Observable
8186
+ * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer
8187
+ * the application of this operator via {@link #defer(Func0)}:
8188
+ * <pre><code>
8189
+ * Observable<T> source = ...
8190
+ * Observable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item)));
8191
+ *
8192
+ * // alternatively, by using compose to stay fluent
8193
+ *
8194
+ * source.compose(o ->
8195
+ * Observable.defer(() -> o.scan(new ArrayList<>(), (list, item) -> list.add(item)))
8196
+ * );
8197
+ * </code></pre>
8170
8198
* <dl>
8199
+ * <dt><b>Backpressure:</b></dt>
8200
+ * <dd>The operator honors backpressure.</dd>
8171
8201
* <dt><b>Scheduler:</b></dt>
8172
8202
* <dd>{@code scan} does not operate by default on a particular {@link Scheduler}.</dd>
8173
8203
* </dl>
0 commit comments