Room and RX Java
up vote
0
down vote
favorite
I have a method in which a data sheet is committed.
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
I need to save them to the database. I work with Room. There is a method
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(NewsEntity... newsEntities);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(NewsEntity newsEntity);
No saving occurs Link
rx-java2 android-room
add a comment |
up vote
0
down vote
favorite
I have a method in which a data sheet is committed.
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
I need to save them to the database. I work with Room. There is a method
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(NewsEntity... newsEntities);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(NewsEntity newsEntity);
No saving occurs Link
rx-java2 android-room
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a method in which a data sheet is committed.
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
I need to save them to the database. I work with Room. There is a method
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(NewsEntity... newsEntities);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(NewsEntity newsEntity);
No saving occurs Link
rx-java2 android-room
I have a method in which a data sheet is committed.
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
I need to save them to the database. I work with Room. There is a method
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(NewsEntity... newsEntities);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(NewsEntity newsEntity);
No saving occurs Link
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
private void saveItemsToDB(List<NewsEntity> newsEntityList) {
Disposable disposable = Completable.fromCallable((Callable<Void>) () -> {
newsDatabase.getNewsDao().deleteAll();
Utils.log("******Delete All******");
for (NewsEntity newsEntity : newsEntityList) {
Utils.log("******Save " + newsEntity + "******");
newsDatabase.getNewsDao().insert(newsEntity);
}
return null;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe();
compositeDisposable.add(disposable);
}
rx-java2 android-room
rx-java2 android-room
edited Nov 19 at 10:07
Agilanbu
901617
901617
asked Nov 19 at 9:44
Сергей Бувака
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
According to RxJava2
documentation, it's not allowed to pass null
through rx chain. I suppose, it's the cause of the problem.
Completable.fromCallable((Callable<Void>) () -> {
...
return null; // don't do this
})
If you don't want to return anything, use Completable.fromAction()
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
According to RxJava2
documentation, it's not allowed to pass null
through rx chain. I suppose, it's the cause of the problem.
Completable.fromCallable((Callable<Void>) () -> {
...
return null; // don't do this
})
If you don't want to return anything, use Completable.fromAction()
add a comment |
up vote
0
down vote
According to RxJava2
documentation, it's not allowed to pass null
through rx chain. I suppose, it's the cause of the problem.
Completable.fromCallable((Callable<Void>) () -> {
...
return null; // don't do this
})
If you don't want to return anything, use Completable.fromAction()
add a comment |
up vote
0
down vote
up vote
0
down vote
According to RxJava2
documentation, it's not allowed to pass null
through rx chain. I suppose, it's the cause of the problem.
Completable.fromCallable((Callable<Void>) () -> {
...
return null; // don't do this
})
If you don't want to return anything, use Completable.fromAction()
According to RxJava2
documentation, it's not allowed to pass null
through rx chain. I suppose, it's the cause of the problem.
Completable.fromCallable((Callable<Void>) () -> {
...
return null; // don't do this
})
If you don't want to return anything, use Completable.fromAction()
answered Nov 19 at 10:18
ConstOrVar
1,024149
1,024149
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371909%2froom-and-rx-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown