Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Created August 14, 2016 16:14
Show Gist options
  • Save ragdroid/b7ac2eea118b031fb61a4d009b7b147b to your computer and use it in GitHub Desktop.
Save ragdroid/b7ac2eea118b031fb61a4d009b7b147b to your computer and use it in GitHub Desktop.
Concat() operator to hit the cache first - Droidcon 2016
//Concatify spell
Observable<List<Lecture>> getLectures() {
Observable<List<Lecture>> cacheObservable = getLecturesFromCache();
Observable<List<Lecture>> lecturesFromServer = getLecturesFromServer();
return cacheObservable.concatWith(lecturesFromServer)
.take(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment