RxJava - fetch every item on the list

前端 未结 5 424
渐次进展
渐次进展 2020-12-13 08:43

I have a method that returns an Observable>, which are ids of some Items. I\'d like to go through this list and download every Item

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 09:36

    For Kotlin

     Observable
            .fromIterable(listOfChallenges) // list of challenges which contain challenge ID
            .flatMap { eachChallenge ->
                getChallengeDetail(eachChallenge.challengeUid!!) // fetch details of each challenge
            }
            .toList() // map to list
            .subscribe({ listOfEachChallengesDetail ->
    
            }, {
                // error
            })
    

提交回复
热议问题