Convert Observable> to a sequence of Observable in RxJava

后端 未结 2 1054
耶瑟儿~
耶瑟儿~ 2021-01-31 06:58

Given a list of cars (List cars), I can do:

Observable.just(cars); //returns an Observable that emits one List
Observable.from         


        
相关标签:
2条回答
  • 2021-01-31 07:40

    You can map an Observable<List<Car>> to Observable<Car> like so:

    yourListObservable.flatMapIterable(x -> x)
    

    Note that flatMapping might not preserve the order of the source observable. If the order matters to you, use concatMapIterable. Read here for more details.

    0 讨论(0)
  • 2021-01-31 07:59

    you can use this

    flatMap { t -> Observable.fromIterable(t) }
    
    0 讨论(0)
提交回复
热议问题