Skip to content

Commit eb6d789

Browse files
committed
Linked to examples
1 parent 509e193 commit eb6d789

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

Part 1 - Getting Started/3. Lifetime management.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Subscription subscribe(Observer<? super T> observer)
1515
Subscription subscribe(Subscriber<? super T> subscriber)
1616
```
1717

18-
`subscribe()` consumes events but performs no actions. The overloads that take one or more `Action` will construct a `Subscriber` with the functions that you provide. Where you don't give an action, the no action is performed.
18+
`subscribe()` consumes events but performs no actions. The overloads that take one or more `Action` will construct a `Subscriber` with the functions that you provide. Where you don't give an action, the event is practically ignored.
1919

2020
In the following example, we handle the error of a sequence that failed.
2121

2222
```java
2323
Subject<Integer, Integer> s = ReplaySubject.create();
2424
s.subscribe(
25-
v -> System.out.println(v),
26-
e -> System.err.println(e));
25+
v -> System.out.println(v),
26+
e -> System.err.println(e));
2727
s.onNext(0);
2828
s.onError(new Exception("Oops"));
2929
```
@@ -59,8 +59,7 @@ values.onNext(1);
5959
subscription.unsubscribe();
6060
values.onNext(2);
6161
```
62-
63-
Output
62+
[Output]/tests/java/itrx/chapter1/UnsubscribingExample.java)
6463
```java
6564
0
6665
1
@@ -82,8 +81,7 @@ subscription1.unsubscribe();
8281
System.out.println("Unsubscribed first");
8382
values.onNext(2);
8483
```
85-
86-
Output
84+
[Output]/tests/java/itrx/chapter1/UnsubscribingExample.java)
8785
```
8886
First: 0
8987
Second: 0
@@ -95,7 +93,7 @@ Second: 2
9593

9694
## onError and onCompleted
9795

98-
`onError` and `onCompleted` mean the termination of a sequence. An observable that complies with the Rx contract will not emit anything after either of those events. This is something to note both when consuming in Rx and when implementing your own observable.
96+
`onError` and `onCompleted` mean the termination of a sequence. An observable that complies with the Rx contract will not emit anything after either of those events. This is something to note both when consuming in Rx and when implementing your own observables.
9997

10098
```java
10199
Subject<Integer, Integer> values = ReplaySubject.create();
@@ -109,8 +107,7 @@ values.onNext(1);
109107
values.onCompleted();
110108
values.onNext(2);
111109
```
112-
113-
Output
110+
[Output](/tests/java/itrx/chapter1/RxContractExample.java)
114111
```
115112
First: 0
116113
First: 1
@@ -125,7 +122,7 @@ A `Subscription` is tied to the resources it uses. For that reason, you should r
125122
Subscription s = Subscriptions.create(() -> System.out.println("Clean"));
126123
s.unsubscribe();
127124
```
128-
Output
125+
[Output](/tests/java/itrx/chapter1/UnsubscribingExample.java)
129126
```
130127
Clean
131128
```

0 commit comments

Comments
 (0)