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
New contributor
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
New contributor
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
New contributor
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
New contributor
New contributor
edited 15 hours ago
Agilanbu
699417
699417
New contributor
asked 15 hours ago
Сергей Бувака
1
1
New contributor
New contributor
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 15 hours ago
ConstOrVar
97948
97948
add a comment |
add a comment |
Сергей Бувака is a new contributor. Be nice, and check out our Code of Conduct.
Сергей Бувака is a new contributor. Be nice, and check out our Code of Conduct.
Сергей Бувака is a new contributor. Be nice, and check out our Code of Conduct.
Сергей Бувака is a new contributor. Be nice, and check out our Code of Conduct.
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