RxJava-有点复杂的API请求,以及进度的详细信息

问题描述 投票:0回答:1

开始时,我只玩过RxJava / RxAndroid几天。

在psuedocode中,当我从Guild Wars 2 API加载数据时,我试图完成类似的事情:

refreshDatabase {
    getAllIds - single API call (50.000+ ids)
    chunk ids into chunks of 100 each
    for each chunk
        getItems - single API call which fetches 100 items
        update ui on the progress (# chunks out of # chunks done)
    loop through all items when all chunks are fetched
        determine if the item is something we're after
            save it in our own database
        update ui on progress (# items out of # items done)
    return bool telling if successful or not
}

我已经阅读了很多有关它的教程和文档,但是我并没有真正掌握如何编写代码。

如果要在将数据块提取后直接将排序/保存到数据库中,则要完成所有工作的逻辑,但是我无法使用详细信息更新UI。

由于此操作在第一次运行时需要花费相当长的时间,因此我希望进度非常详细,而不是节省0.5-2秒的加载时间。

关于获取方法的任何技巧都使其类似于伪代码中的内容?

首先,我只使用RxJava / RxAndroid玩了几天。在psuedocode中,当我从Guild Wars 2 API加载数据时,我正在尝试完成以下操作:...

rx-java2 rx-android
1个回答
0
投票

征服。

© www.soinside.com 2019 - 2024. All rights reserved.