Last active
June 2, 2016 14:32
-
-
Save daschl/11252782 to your computer and use it in GitHub Desktop.
Official Couchbase Java SDK Preview - Document Loading
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
// Load 3 Documents and process them one after another | |
// Java 8: | |
Observable | |
.from("doc1", "doc2", "doc3") | |
.flatMap(id -> bucket.get(id)) | |
.subscribe(doc -> System.out.println(doc)); | |
// Java 6 & 7 | |
Observable | |
.from("doc1", "doc2", "doc3") | |
.flatMap(new Func1<String, Observable<Document>>() { | |
@Override | |
public Observable<Document> call(String id) { | |
return bucket.get(id); | |
} | |
}) | |
.subscribe(new Action1<Document>() { | |
@Override | |
public void call(Document doc) { | |
System.out.println(doc); | |
} | |
}); |
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
// Load 3 Documents and process them together | |
// Java 8: | |
Observable | |
.from("doc1", "doc2", "doc3") | |
.flatMap(id -> bucket.get(id)) | |
.toList() | |
.subscribe(docs -> System.out.println(docs)); | |
// Java 6 & 7 | |
Observable | |
.from("doc1", "doc2", "doc3") | |
.flatMap(new Func1<String, Observable<Document>>() { | |
@Override | |
public Observable<Document> call(String id) { | |
return bucket.get(id); | |
} | |
}) | |
.toList() | |
.subscribe(new Action1<List<Document>>() { | |
@Override | |
public void call(List<Document> docs) { | |
System.out.println(docs) | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment