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:
Observable.just('S').subscribe(System.out::println);
Or a sequence of letters:
Observable .just('R', 'x', 'J', 'a', 'v', 'a') .subscribe( System.out::print, System.err::println, System.out::println );
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...