Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 410f885

Browse files
committed
Merge pull request Froussios#6 from Froussios/Tests-and-examples
Wrote examples, tests for examples and linked from text
2 parents 8b5443a + 899c1d2 commit 410f885

File tree

111 files changed

+11254
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+11254
-220
lines changed

Part 1 - Getting Started/2. Key types.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static void main(String[] args) {
7373
subject.onNext(4);
7474
}
7575
```
76-
Output
76+
[Output](/tests/java/itrx/chapter1/PublishSubjectExample.java)
7777
```
7878
2
7979
3
@@ -100,7 +100,7 @@ s.onNext(1);
100100
s.subscribe(v -> System.out.println("Late: " + v));
101101
s.onNext(2);
102102
```
103-
Output
103+
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
104104
```
105105
Early:0
106106
Early:1
@@ -122,8 +122,7 @@ s.onNext(2);
122122
s.subscribe(v -> System.out.println("Late: " + v));
123123
s.onNext(3);
124124
```
125-
126-
Output
125+
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
127126
```
128127
Late: 1
129128
Late: 2
@@ -144,8 +143,7 @@ s.onNext(2);
144143
s.subscribe(v -> System.out.println("Late: " + v));
145144
s.onNext(3);
146145
```
147-
148-
Output
146+
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
149147
```
150148
Late: 1
151149
Late: 2
@@ -168,8 +166,7 @@ s.onNext(2);
168166
s.subscribe(v -> System.out.println("Late: " + v));
169167
s.onNext(3);
170168
```
171-
172-
output
169+
[Output](/tests/java/itrx/chapter1/BehaviorSubjectExample.java)
173170
```
174171
Late: 2
175172
Late: 3
@@ -197,8 +194,7 @@ BehaviorSubject<Integer> s = BehaviorSubject.create(0);
197194
s.subscribe(v -> System.out.println(v));
198195
s.onNext(1);
199196
```
200-
201-
Output
197+
[Output](/tests/java/itrx/chapter1/BehaviorSubjectExample.java)
202198
```
203199
0
204200
1
@@ -218,8 +214,7 @@ s.onNext(1);
218214
s.onNext(2);
219215
s.onCompleted();
220216
```
221-
222-
Output
217+
[Output](/tests/java/itrx/chapter1/AsyncSubjectExample.java)
223218
```
224219
2
225220
```
@@ -238,7 +233,7 @@ s.onCompleted();
238233
s.onNext(1);
239234
s.onNext(2);
240235
```
241-
Output
236+
[Output](/tests/java/itrx/chapter1/RxContractExample.java)
242237
```
243238
0
244239
```

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

Lines changed: 9 additions & 12 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,9 +59,8 @@ values.onNext(1);
5959
subscription.unsubscribe();
6060
values.onNext(2);
6161
```
62-
63-
Output
64-
```java
62+
[Output](/tests/java/itrx/chapter1/UnsubscribingExample.java)
63+
```
6564
0
6665
1
6766
```
@@ -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
```

Part 2 - Sequence Basics/1. Creating a sequence.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Subscription subscription = values.subscribe(
2020
() -> System.out.println("Completed")
2121
);
2222
```
23-
24-
Output
23+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
2524
```
2625
Received: one
2726
Received: two
@@ -41,8 +40,7 @@ Subscription subscription = values.subscribe(
4140
() -> System.out.println("Completed")
4241
);
4342
```
44-
45-
Output
43+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
4644
```
4745
Completed
4846
```
@@ -60,7 +58,7 @@ Subscription subscription = values.subscribe(
6058
);
6159
```
6260

63-
The above code will print nothing. Note that this doesn't mean that the program is blocking. In fact, it will terminate immediately.
61+
The [code above](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java) will print nothing. Note that this doesn't mean that the program is blocking. In fact, it will terminate immediately.
6462

6563
### Observable.error
6664

@@ -74,8 +72,7 @@ Subscription subscription = values.subscribe(
7472
() -> System.out.println("Completed")
7573
);
7674
```
77-
78-
Output
75+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
7976
```
8077
Error: java.lang.Exception: Oops
8178
```
@@ -91,7 +88,7 @@ now.subscribe(System.out::println);
9188
Thread.sleep(1000);
9289
now.subscribe(System.out::println);
9390
```
94-
Output
91+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
9592
```
9693
1431443908375
9794
1431443908375
@@ -107,7 +104,7 @@ now.subscribe(System.out::println);
107104
Thread.sleep(1000);
108105
now.subscribe(System.out::println);
109106
```
110-
Output
107+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
111108
```
112109
1431444107854
113110
1431444108858
@@ -134,7 +131,7 @@ Subscription subscription = values.subscribe(
134131
() -> System.out.println("Completed")
135132
);
136133
```
137-
Output
134+
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
138135
```
139136
Received: Hello
140137
Completed
@@ -160,7 +157,7 @@ A straight forward and familiar method to any functional programmer. It emits th
160157
Observable<Integer> values = Observable.range(10, 15);
161158
```
162159

163-
The example emits the values from 10 to 24 in sequence.
160+
The [example](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java) emits the values from 10 to 24 in sequence.
164161

165162
### Observable.interval
166163

@@ -175,8 +172,7 @@ Subscription subscription = values.subscribe(
175172
);
176173
System.in.read();
177174
```
178-
179-
Output
175+
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
180176
```
181177
Received: 0
182178
Received: 1
@@ -201,7 +197,7 @@ Subscription subscription = values.subscribe(
201197
() -> System.out.println("Completed")
202198
);
203199
```
204-
Output
200+
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
205201
```
206202
Received: 0
207203
Completed
@@ -217,7 +213,7 @@ Subscription subscription = values.subscribe(
217213
() -> System.out.println("Completed")
218214
);
219215
```
220-
output
216+
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
221217
```
222218
Received: 0
223219
Received: 1
@@ -267,8 +263,7 @@ Subscription subscription = values.subscribe(
267263
() -> System.out.println("Completed")
268264
);
269265
```
270-
271-
Output
266+
[Output](/tests/java/itrx/chapter2/creating/FromExample.java)
272267
```
273268
Received: 21
274269
Completed
@@ -293,8 +288,7 @@ Subscription subscription = values.subscribe(
293288
() -> System.out.println("Completed")
294289
);
295290
```
296-
297-
Output
291+
[Output](/tests/java/itrx/chapter2/creating/FromExample.java)
298292
```
299293
Received: 1
300294
Received: 2

0 commit comments

Comments
 (0)