Created
October 22, 2015 23:24
-
-
Save metalmatze/79cc9bde9cf019e2b906 to your computer and use it in GitHub Desktop.
Retrofit returning a observable which is mapped and then copied into the realm Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Api.with(getActivity()).request() | |
.authors() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.map(authorJsonArray -> authorJsonArray.data) | |
.subscribe(authors -> { | |
realm.beginTransaction(); | |
realm.copyToRealmOrUpdate(authors); | |
realm.commitTransaction(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment