当前位置: 动力学知识库 > 问答 > 编程问答 >

android - rxjava + retrofit streaming one by one a long list of data

问题描述:

I need to get list of users:

API Endpoint:

Observable<List<User>> getUsers();

onNext(List<User> usersList)

I do not want to wait for the download of entire list.

I want to get user one by one.

Like this:

onNext(TempData singleUser)

how can I do that?

网友答案:

If you just want to convert Observable<List<User>> to Observable<User>, you can use getUsers().flatMapIterable(l -> l).

If you want to downloads and process the user list one by one, you need to change your API, since Observable<List<User>> getUsers() won't emit anything until the whole list is downloaded.

分享给朋友:
您可能感兴趣的文章:
随机阅读: