O'Reilly logo

Learning Reactive Programming with Java 8 by Nickolay Tsvetinov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An HTTP client example

Let's use RxJava to retrieve information about the GitHub repositories of a user by username. We will use our subscribePrint() function used previously to output the information to the system output. The idea of the program is to display all of the public repositories of the user that are not forks. The main part of the program looks like this:

String username = "meddle0x53";
Observable<Map> resp = githubUserInfoRequest(client, username);
subscribePrint(
  resp
  .map(json ->
    json.get("name") + "(" + json.get("language") + ")"),
  "Json"
);

This program uses my user (it can be easily reworked to use a username passed as a parameter) to retrieve information its public repositories. It prints the name of each repository and the main ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required