-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathCreatingObservablesUsingJust.java
More file actions
60 lines (44 loc) · 1.19 KB
/
CreatingObservablesUsingJust.java
File metadata and controls
60 lines (44 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.packtpub.reactive.chapter03;
import rx.Observable;
import com.packtpub.reactive.common.Program;
/**
* Demonstrates using Observable.just for creating Observables.
*
* @author meddle
*/
public class CreatingObservablesUsingJust implements Program {
@Override
public String name() {
return "Using the Observable.just method to create Observables";
}
@Override
public int chapter() {
return 3;
}
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;
}
}
@Override
public void run() {
Observable.just('S').subscribe(System.out::println);
Observable.just('R', 'x', 'J', 'a', 'v', 'a').subscribe(
System.out::print, System.err::println, System.out::println);
Observable.just(new User("Dali", "Bali"))
.map(u -> u.getForename() + " " + u.getLastname())
.subscribe(System.out::println);
}
public static void main(String[] args) {
new CreatingObservablesUsingJust().run();
}
}