Skip to content

Instantly share code, notes, and snippets.

@rohmanhakim
Created January 4, 2017 15:33
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 rohmanhakim/d2322239e201238f82ab94f29b55288a to your computer and use it in GitHub Desktop.
Save rohmanhakim/d2322239e201238f82ab94f29b55288a 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
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment