Skip to content

Commit 1a10f05

Browse files
author
jmhofer
committed
Merge branch 'master' into sample
2 parents 2263eb8 + 96d38a3 commit 1a10f05

14 files changed

+871
-92
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# RxJava Releases #
22

3+
### Version 0.8.1 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.8.1%22)) ###
4+
5+
* [Pull 250](https://github.com/Netflix/RxJava/pull/250) AsyncSubject
6+
* [Pull 252](https://github.com/Netflix/RxJava/pull/252) ToFuture
7+
* [Pull 246](https://github.com/Netflix/RxJava/pull/246) Scheduler.schedulePeriodically
8+
* [Pull 247](https://github.com/Netflix/RxJava/pull/247) flatMap aliased to mapMany
9+
310
### Version 0.8.0 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.8.0%22)) ###
411

512
This is a breaking (non-backwards compatible) release that updates the Scheduler implementation released in 0.7.0.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.8.1-SNAPSHOT
1+
version=0.8.2-SNAPSHOT

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 148 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
import rx.operators.OperationConcat;
4343
import rx.operators.OperationDefer;
4444
import rx.operators.OperationDematerialize;
45-
import rx.operators.OperationGroupBy;
4645
import rx.operators.OperationFilter;
4746
import rx.operators.OperationFinally;
47+
import rx.operators.OperationGroupBy;
4848
import rx.operators.OperationMap;
4949
import rx.operators.OperationMaterialize;
5050
import rx.operators.OperationMerge;
@@ -64,6 +64,7 @@
6464
import rx.operators.OperationTakeLast;
6565
import rx.operators.OperationTakeUntil;
6666
import rx.operators.OperationTakeWhile;
67+
import rx.operators.OperationToFuture;
6768
import rx.operators.OperationToIterator;
6869
import rx.operators.OperationToObservableFuture;
6970
import rx.operators.OperationToObservableIterable;
@@ -590,9 +591,11 @@ public void call(Object args) {
590591

591592
/**
592593
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
593-
*
594-
* @param subject the subject to push source elements into.
595-
* @param <R> result type
594+
*
595+
* @param subject
596+
* the subject to push source elements into.
597+
* @param <R>
598+
* result type
596599
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
597600
*/
598601
public <R> ConnectableObservable<R> multicast(Subject<T, R> subject) {
@@ -1172,6 +1175,8 @@ public R call(T t1) {
11721175
* and then merges the results of that function applied to every item emitted by the original
11731176
* Observable, emitting these merged results as its own sequence.
11741177
* <p>
1178+
* Note: mapMany and flatMap are equivalent.
1179+
* <p>
11751180
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
11761181
*
11771182
* @param sequence
@@ -1186,6 +1191,7 @@ public R call(T t1) {
11861191
* @return an Observable that emits a sequence that is the result of applying the transformation
11871192
* function to each item emitted by the source Observable and merging the results of
11881193
* the Observables obtained from this transformation
1194+
* @see {@link #flatMap(Observable, Func1)}
11891195
*/
11901196
public static <T, R> Observable<R> mapMany(Observable<T> sequence, Func1<T, Observable<R>> func) {
11911197
return create(OperationMap.mapMany(sequence, func));
@@ -1351,6 +1357,62 @@ public static <T> Observable<T> finallyDo(Observable<T> source, Action0 action)
13511357
return create(OperationFinally.finallyDo(source, action));
13521358
}
13531359

1360+
/**
1361+
* Creates a new Observable sequence by applying a function that you supply to each object in the
1362+
* original Observable sequence, where that function is itself an Observable that emits objects,
1363+
* and then merges the results of that function applied to every item emitted by the original
1364+
* Observable, emitting these merged results as its own sequence.
1365+
* <p>
1366+
* Note: mapMany and flatMap are equivalent.
1367+
* <p>
1368+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1369+
*
1370+
* @param sequence
1371+
* the source Observable
1372+
* @param func
1373+
* a function to apply to each item emitted by the source Observable, generating a
1374+
* Observable
1375+
* @param <T>
1376+
* the type emitted by the source Observable
1377+
* @param <R>
1378+
* the type emitted by the Observables emitted by <code>func</code>
1379+
* @return an Observable that emits a sequence that is the result of applying the transformation
1380+
* function to each item emitted by the source Observable and merging the results of
1381+
* the Observables obtained from this transformation
1382+
* @see {@link #mapMany(Observable, Func1)}
1383+
*/
1384+
public static <T, R> Observable<R> flatMap(Observable<T> sequence, Func1<T, Observable<R>> func) {
1385+
return mapMany(sequence, func);
1386+
}
1387+
1388+
/**
1389+
* Creates a new Observable sequence by applying a function that you supply to each object in the
1390+
* original Observable sequence, where that function is itself an Observable that emits objects,
1391+
* and then merges the results of that function applied to every item emitted by the original
1392+
* Observable, emitting these merged results as its own sequence.
1393+
* <p>
1394+
* Note: mapMany and flatMap are equivalent.
1395+
* <p>
1396+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
1397+
*
1398+
* @param sequence
1399+
* the source Observable
1400+
* @param func
1401+
* a function to apply to each item emitted by the source Observable, generating a
1402+
* Observable
1403+
* @param <T>
1404+
* the type emitted by the source Observable
1405+
* @param <R>
1406+
* the type emitted by the Observables emitted by <code>func</code>
1407+
* @return an Observable that emits a sequence that is the result of applying the transformation
1408+
* function to each item emitted by the source Observable and merging the results of
1409+
* the Observables obtained from this transformation
1410+
* @see {@link #mapMany(Observable, Func1)}
1411+
*/
1412+
public static <T, R> Observable<R> flatMap(Observable<T> sequence, final Object func) {
1413+
return mapMany(sequence, func);
1414+
}
1415+
13541416
/**
13551417
* Groups the elements of an observable and selects the resulting elements by using a specified function.
13561418
*
@@ -2005,6 +2067,19 @@ public Boolean call(T t, Integer integer)
20052067
}));
20062068
}
20072069

2070+
/**
2071+
* Return a Future representing a single value of the Observable.
2072+
* <p>
2073+
* This will throw an exception if the Observable emits more than 1 value. If more than 1 are expected then use <code>toList().toFuture()</code>.
2074+
*
2075+
* @param that
2076+
* the source Observable
2077+
* @returna Future that expects a single item emitted by the source Observable
2078+
*/
2079+
public static <T> Future<T> toFuture(final Observable<T> that) {
2080+
return OperationToFuture.toFuture(that);
2081+
}
2082+
20082083
/**
20092084
* Returns an Observable that emits a single item, a list composed of all the items emitted by
20102085
* the source Observable.
@@ -2088,11 +2163,15 @@ public static <T> Iterable<T> mostRecent(Observable<T> source, T initialValue) {
20882163

20892164
/**
20902165
* Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
2091-
*
2092-
* @param source the source sequence whose elements will be pushed into the specified subject.
2093-
* @param subject the subject to push source elements into.
2094-
* @param <T> source type
2095-
* @param <R> result type
2166+
*
2167+
* @param source
2168+
* the source sequence whose elements will be pushed into the specified subject.
2169+
* @param subject
2170+
* the subject to push source elements into.
2171+
* @param <T>
2172+
* source type
2173+
* @param <R>
2174+
* result type
20962175
* @return a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
20972176
*/
20982177
public static <T, R> ConnectableObservable<R> multicast(Observable<T> source, final Subject<T, R> subject) {
@@ -2101,7 +2180,7 @@ public static <T, R> ConnectableObservable<R> multicast(Observable<T> source, fi
21012180

21022181
/**
21032182
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
2104-
*
2183+
*
21052184
* @param that
21062185
* the source Observable
21072186
* @return The single element in the observable sequence.
@@ -2670,6 +2749,48 @@ public Boolean call(T t1) {
26702749
});
26712750
}
26722751

2752+
/**
2753+
* Creates a new Observable sequence by applying a function that you supply to each item in the
2754+
* original Observable sequence, where that function is itself an Observable that emits items, and
2755+
* then merges the results of that function applied to every item emitted by the original
2756+
* Observable, emitting these merged results as its own sequence.
2757+
* <p>
2758+
* Note: mapMany and flatMap are equivalent.
2759+
* <p>
2760+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2761+
*
2762+
* @param func
2763+
* a function to apply to each item in the sequence, that returns an Observable.
2764+
* @return an Observable that emits a sequence that is the result of applying the transformation
2765+
* function to each item in the input sequence and merging the results of the
2766+
* Observables obtained from this transformation.
2767+
* @see {@link #mapMany(Func1)}
2768+
*/
2769+
public <R> Observable<R> flatMap(Func1<T, Observable<R>> func) {
2770+
return mapMany(func);
2771+
}
2772+
2773+
/**
2774+
* Creates a new Observable sequence by applying a function that you supply to each item in the
2775+
* original Observable sequence, where that function is itself an Observable that emits items, and
2776+
* then merges the results of that function applied to every item emitted by the original
2777+
* Observable, emitting these merged results as its own sequence.
2778+
* <p>
2779+
* Note: mapMany and flatMap are equivalent.
2780+
* <p>
2781+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
2782+
*
2783+
* @param callback
2784+
* a function to apply to each item in the sequence that returns an Observable.
2785+
* @return an Observable that emits a sequence that is the result of applying the transformation'
2786+
* function to each item in the input sequence and merging the results of the
2787+
* Observables obtained from this transformation.
2788+
* @see {@link #mapMany(Object)}
2789+
*/
2790+
public <R> Observable<R> flatMap(final Object callback) {
2791+
return mapMany(callback);
2792+
}
2793+
26732794
/**
26742795
* Filters an Observable by discarding any of its emissions that do not meet some test.
26752796
* <p>
@@ -2805,13 +2926,16 @@ public R call(T t1) {
28052926
* then merges the results of that function applied to every item emitted by the original
28062927
* Observable, emitting these merged results as its own sequence.
28072928
* <p>
2929+
* Note: mapMany and flatMap are equivalent.
2930+
* <p>
28082931
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
28092932
*
28102933
* @param func
28112934
* a function to apply to each item in the sequence, that returns an Observable.
28122935
* @return an Observable that emits a sequence that is the result of applying the transformation
28132936
* function to each item in the input sequence and merging the results of the
28142937
* Observables obtained from this transformation.
2938+
* @see {@link #flatMap(Func1)}
28152939
*/
28162940
public <R> Observable<R> mapMany(Func1<T, Observable<R>> func) {
28172941
return mapMany(this, func);
@@ -2823,13 +2947,16 @@ public <R> Observable<R> mapMany(Func1<T, Observable<R>> func) {
28232947
* then merges the results of that function applied to every item emitted by the original
28242948
* Observable, emitting these merged results as its own sequence.
28252949
* <p>
2950+
* Note: mapMany and flatMap are equivalent.
2951+
* <p>
28262952
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/mapMany.png">
28272953
*
28282954
* @param callback
28292955
* a function to apply to each item in the sequence that returns an Observable.
28302956
* @return an Observable that emits a sequence that is the result of applying the transformation'
28312957
* function to each item in the input sequence and merging the results of the
28322958
* Observables obtained from this transformation.
2959+
* @see {@link #flatMap(Object))}
28332960
*/
28342961
public <R> Observable<R> mapMany(final Object callback) {
28352962
@SuppressWarnings("rawtypes")
@@ -3360,6 +3487,17 @@ public <E> Observable<T> takeUntil(Observable<E> other) {
33603487
return takeUntil(this, other);
33613488
}
33623489

3490+
/**
3491+
* Return a Future representing a single value of the Observable.
3492+
* <p>
3493+
* This will throw an exception if the Observable emits more than 1 value. If more than 1 are expected then use <code>toList().toFuture()</code>.
3494+
*
3495+
* @returna Future that expects a single item emitted by the source Observable
3496+
*/
3497+
public Future<T> toFuture() {
3498+
return toFuture(this);
3499+
}
3500+
33633501
/**
33643502
* Returns an Observable that emits a single item, a list composed of all the items emitted by
33653503
* the source Observable.

0 commit comments

Comments
 (0)