2017-03-09 91 views

回答

0

你嘗試CombineLatest(http://reactivex.io/documentation/operators/combinelatest.html

基本上可以發射A和B,然後基於所述函數結果返回另一個目的:

RXJava1

Observable 
    .combineLatest([Add here your A observable], 
       [Add here your B observable], 
       new Func2<A, B, Result>() { 
        @Override 
        public Result call(A a, B b) { 
         //Do your stuff here combining both results and return the result expected 
        } 
       }) 

RXJava2

Observable 
    .combineLatest([Add here your A observable], 
       [Add here your B observable], 
       new BiFunction<A, B, Result>() { 
        @Override 
        public Result apply(A a, B b) throws Exception { 
         //Do your stuff here combining both results and return the result expected 
        } 
       })