Created
April 15, 2016 09:02
-
-
Save ChrisLowe-Takor/b1cf0070a328f49192faa6ee4da21fcc to your computer and use it in GitHub Desktop.
Android RxJava zip two observables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Say you have two observables (Bar and Baz) you want to combine into a single output (Foo) | |
public Observable<Foo> combineObservables(Observable<Bar> barObservable, Observable<Baz> bazObservable) { | |
return Observable.zip( | |
barObservable, | |
bazObservable, | |
new Func2<Bar, Baz, Foo>() { | |
@Override | |
public Foo call(Bar bar, Baz baz) { | |
return new Foo(bar, baz) | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment