Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Data里的loadFromNetwork的疑问 #25

Open
fancyhugo opened this issue Jul 13, 2017 · 0 comments
Open

关于Data里的loadFromNetwork的疑问 #25

fancyhugo opened this issue Jul 13, 2017 · 0 comments

Comments

@fancyhugo
Copy link

Network.getGankApi()
.getBeauties(100, 1)
.subscribeOn(Schedulers.io())
.map(GankBeautyResultToItemsMapper.getInstance())
.doOnNext(new Action1<List>() {
@OverRide
public void call(List items) {
Database.getInstance().writeItems(items);
}
})
.subscribe(new Action1<List>() {
@OverRide
public void call(List items) {
cache.onNext(items);
}
}, new Action1() {
@OverRide
public void call(Throwable throwable) {
throwable.printStackTrace();
}
});
从网路获取数据后执行doOnNext先写入数据库,然后才执行subscribe里的call,这样就是网络获取数据后先写数据库再更新UI,我理解的没错吧?
实际应用中这种方式应该不可取吧,rxjava新手,这种类型的需求应该很普遍吧,实际应该应该怎么使用呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant