简体   繁体   English

RxJava:虚假合并可观察调用onComplete

[英]RxJava: Merged observable calls onComplete spuriously

I have several observervables I merge from a set. 我从集合中合并了几个观察者对象。 For some reason, the merged observable is calling onComplete, even though the individual observables are not. 由于某些原因,合并的可观察对象正在调用onComplete,即使单个可观察对象不是。

Example: 例:

Set<Observable<InputOutputEvent>> set = new HashSet<Observable<InputOutputEvent>>();
    for (Observable ob : obs) {
        ob.subscribe((e) -> {
        }, 
        (error) -> {
System.out.println("This does NOT happen.");
        }, 
        () -> {
            System.out.println("This does NOT happen.");
        });
        set.add(c.event());
    }

  Subscription s = Observable.merge(set).subscribe((e) -> {
            }, 
            (error) -> {
                System.out.println("This does NOT happen.");
            }, 
            () -> {
                System.out.println("This DOES happen.");
            });

How is that possible? 那怎么可能? Isn't the merge observable supposed to only call onComplete when all the merged ones have called it? 难道不是只有所有合并的对象都调用了onComplete时,它才能被观察到吗?

I've also checked for errors, but there are none. 我也检查了错误,但是没有。

Leaving this as a caution to others: 谨此提醒其他人:

The set of observables was EMPTY. 可观察值的set为空。 onComplete was called immediately in this case. 在这种情况下,将立即调用onComplete。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM