Java – combine two different types of observable
•
Java
See English answers > rxjava merge observables of different types
@Override public void call(String s,Boolean b) { }
After the two operations are completed?
Solution
When you want to wait for items sent from two observable (synchronize them), you usually need to be like observable Zip:
Observable<String> o1 = Observable.just("a","b","c"); Observable<Integer> o2 = Observable.just(1,2,3); Observable<String> result = Observable.zip(o1,o2,(a,b) -> a + b);
The result will be an observable application of (a, b) – > A to O1 and O2 Results in observable yielding "A1", "B2", "C3"
You can also make obervable Zipwith is used with the actual instance to achieve the same effect
Note that this terminates on the shorter observable when there is nothing to compress
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码