Rx Observable share()与skip()使用问题

时间:2015-12-17 09:37:39

标签: rx-java

我有一个代码,其中使用了共享的observable。其中一个共享实例使用额外的跳过和去抖操作符。问题是,有时使用跳过和去抖动的实例的动作不称为

Observable<Integer> beginChanged = RxBindingUtils
        .valueChanged(begin)
        .doOnEach(value -> Timber.d("Begin value changed: " + value.getValue()))
        .share();

monitor(
        beginChanged
                .map(minutes -> minutesToTime(minutes))
                .subscribe(beginTime.asAction()));
monitor(
        beginChanged
                .map(minutes -> minutes / interval)
                .subscribe(rangeBegin.asAction()));
monitor(
        beginChanged 
                .skip(1)// skip initial value emitted automatically right after the
                        // subsription
                .debounce(500, TimeUnit.MILLISECONDS)// such as range bar may change the
                        // value very quickly use the
                        // debounce function for the timeout
                        // based processing
                .doOnEach(value -> Timber.d("Begin value changed 2: " + value.getValue()))
                .subscribe(mSchedulerRangeBegin.asAction()));

如果我用新的observable替换最后一次出现的beginChanges,它会按预期工作

monitor(
        RxBindingUtils
                .valueChanged(begin) // can't use shared observable because of unexpected behaviour with skip call
                .skip(1)// skip initial value emitted automatically right after the
                        // subsription
                .debounce(500, TimeUnit.MILLISECONDS)// such as range bar may change the
                        // value very quickly use the
                        // debounce function for the timeout
                        // based processing
                .doOnEach(value -> Timber.d("Begin value changed 2: " + value.getValue()))
                .subscribe(mSchedulerRangeBegin.asAction()));

是否有任何限制不允许对共享的可观察对象使用跳过和去抖?

0 个答案:

没有答案