【问题标题】:Convert Rxjava Completable to Map将 Rxjava Completable 转换为 Map
【发布时间】:2019-07-21 20:19:52
【问题描述】:

我需要在链中调用一个可完成的方法,完成后,它需要使用Map 运算符继续链
示例

Single.just(someOperation())
     .flatMapCompletable{
         completableMethod()
    }
     .map{ // i need to continue here with map or some other operator
         doSomeOperation()
    }

谁能帮我解决这个问题?

【问题讨论】:

    标签: android rx-java rx-java2 rx-kotlin2


    【解决方案1】:

    Completable 不提交任何数据。因此,您不能致电map。如果您想在此之后执行任何操作,请使用andThen

    Single.just(someOperation())
         .flatMapCompletable{
             completableMethod()
        }
         .andThen{ 
             doSomeOperation()
        }
    

    More about andThen

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多