【问题标题】:How to emit a boolean only when the previous one is different using Rx Operator? [duplicate]仅当使用 Rx 运算符与前一个不同时,如何发出布尔值? [复制]
【发布时间】:2017-10-11 14:02:03
【问题描述】:

我有一个布尔型 Observable。仅当当前布尔值与预览不同时,我才想发出值(另一个布尔值)。

booleanObservable

            // which operator here

            .subscribe(new Consumer<Boolean>() {
                @Override
                public void accept(Boolean emittedBoolean) throws Exception {
                    // do something with emittedBoolean
                }
            });

【问题讨论】:

  • Observable.distinctUntilChanged
  • 检查this问题。
  • @DeanXu 工作!谢谢

标签: rx-java2 reactivex


【解决方案1】:

你应该使用这个:distinctUntilChanged()

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-20
    • 1970-01-01
    • 2010-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多