Rxjava2 just method - how to run room insertion on another thread?
Even better, you could use a Completable
. Its description: Represents a computation without any value but only indication for completion or exception.
Completable.fromAction(() -> db.countriesDao().addCountries(list)).subscribe();
This is a common mistake: just()
won't execute the "code" within its parenthesis as just
takes a value, not a computation. You need fromCallable
:
Observable.fromCallable(() -> db.countriesDao().addCountries(countriesList))