Last active
August 29, 2015 14:03
-
-
Save maggandalf/ef8791fcfa7a35f4049c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@GET | |
@Path("{isbn}") | |
@Produces(MediaType.APPLICATION_JSON) | |
public void bookAndComment(@Suspended final AsyncResponse asyncResponse, @PathParam("isbn") String isbn) { | |
//Calling previous defined functions | |
Observable<JsonObject> bookInfo = getBookInfo(isbn); | |
Observable<JsonArray> comments = getComments(isbn); | |
Observable.zip(bookInfo, comments, (JsonObject book, JsonArray bookcomments) -> | |
Json.createObjectBuilder().add("book", book).add("comments", bookcomments).build() | |
) | |
.subscribe(new Subscriber<JsonObject>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override | |
public void onError(Throwable e) { | |
asyncResponse.resume(e); | |
} | |
@Override | |
public void onNext(JsonObject jsonObject) { | |
asyncResponse.resume(jsonObject); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment