RxJava Return single, execute completable after

前端 未结 4 542
一生所求
一生所求 2021-02-13 18:58

I\'m trying to accomplish the following: Return some data as single, execute a completable after. The following code does not compile due to single.andThen(). The actions need t

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 20:03

    If anyone is interested in a the RxSwift solution:

    saveObjectsA().flatMap { (objectsA: [A]) -> Single in
            B.objects = objectsA
            return completable.andThen(Single.just(true))
        }
    

    saveObjectsA returns a Single<[A]> which is an attribute of B (created previously). I needed to save it before saving B.

提交回复
热议问题