为什么Observable.zip不调用finallyDo?

时间:2016-05-06 11:25:49

标签: java android rx-java rx-android

简单地说,我有这个代码。但是最后DoDo永远不会被称为Observable.zip ......为什么?

Observable<Integer> observable1 = Observable.just(1);
Observable<Integer> observable2 = Observable.just(2);
Observable<Double> observable = Observable.zip(
    observable1,
    observable2, 
    (Func2)(t1,t2)->{return (double)t1/(double)t2;}
);
observable.finallyDo(()-> {Log.e("","Done");});//is never called;
observable.subscribe(observer);

1 个答案:

答案 0 :(得分:4)

Observable不使用Builder模式,因此您应该订阅从finallyDo()返回的实例:

observable.finallyDo(()-> {Log.e("","Done");}).subscribe()