Skip to content

Instantly share code, notes, and snippets.

@metalmatze
Created October 22, 2015 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metalmatze/79cc9bde9cf019e2b906 to your computer and use it in GitHub Desktop.
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
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