Skip to content

Instantly share code, notes, and snippets.

@rohmanhakim
Created January 4, 2017 04:42
Show Gist options
  • Save rohmanhakim/c6b8473dca2a71c812bb911b5406e6ba to your computer and use it in GitHub Desktop.
Save rohmanhakim/c6b8473dca2a71c812bb911b5406e6ba to your computer and use it in GitHub Desktop.
// Ambil daftar email dari APi, kemudian cek apakah email user sudah dipakai
public Observable<Boolean> checkIfEmailExistFromAPI(final String input){
return service.getEmails()
.flatMap(new Func1<List<String>, Observable<String>>() { // Mengubah stream of List<String> menjadi stream of String
@Override
public Observable<String> call(List<String> strings) {
return Observable.from(strings);
}
}).contains(input); // Cek apakah email di emit oleh stream sebelumnya
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment