Book Image

Learning Reactive Programming with Java 8

By : Nickolay Tzvetinov
Book Image

Learning Reactive Programming with Java 8

By: Nickolay Tzvetinov

Overview of this book

Table of Contents (15 chapters)
Learning Reactive Programming with Java 8
About the Author
About the Reviewers

The Observable.just method

The just() method emits its parameter(s) as OnNext notifications, and after that, it emits an OnCompleted notification.

For example, one letter:


Or a sequence of letters:

  .just('R', 'x', 'J', 'a', 'v', 'a')

The first piece of code prints S and a new line, and the second prints the letters on a single line and adds a new line on completion. The method allows up to nine arbitrary values (objects of the same type) to be observed through reactive means. For example, say we have this simple User class:

public static class User {
  private final String forename;
  private final String lastname;
  public User(String forename, String lastname) {
    this.forename = forename;
    this.lastname = lastname;
  public String getForename() {
    return this.forename;
  public String getLastname() {
    return this.lastname...