X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
78ec4e6
Test for ReplaySubject
Froussios Apr 28, 2015
e29eee6
Added every ReplaySubject example
Froussios Apr 28, 2015
23d6acd
Chapter 1 Examples
Froussios Apr 29, 2015
8980892
Organised examples for chapter 1
Froussios May 3, 2015
3b1f243
Examples chapter 2.1
Froussios May 3, 2015
04043f3
Examples 2.3 Inspection
Froussios May 3, 2015
3101649
Examples 2.4 Aggregation
Froussios May 3, 2015
111ff51
Examples 2.3 Reducing
Froussios May 3, 2015
d608e8f
Examples 2.5 Transforming
Froussios May 3, 2015
33e1aff
Removed warnings
Froussios May 3, 2015
3aee7f3
Examples 3.1 Side effects
Froussios May 6, 2015
abf86ec
Example 3.3 Advanced error handling
Froussios May 6, 2015
34a0d4b
Examples 3.4 combining sequences
Froussios May 6, 2015
c532ddd
Examples 3.5 Time-shifted sequences
Froussios May 7, 2015
917078c
Fixed warning
Froussios May 7, 2015
9bd4441
Examples 3.6 Hot and cold observables
Froussios May 7, 2015
9a2fc21
Examples 3.7 Custom operators
Froussios May 7, 2015
16838e4
Examples 4.1 Scheduling
Froussios May 8, 2015
b8aec3a
3.6 Added examples for replay overloads
Froussios May 8, 2015
220df5e
Examples 4.2 Testing
Froussios May 8, 2015
e792fc8
Examples 4.3 Coincidence
Froussios May 9, 2015
08d7f62
Examples 4.4 Backpressure
Froussios May 9, 2015
ca59ab3
Examples 3.2 Leaving the monad
Froussios May 9, 2015
b05874a
Added example `collect` for 2.4
Froussios May 12, 2015
cf4e31c
Added example `defer` for 2.1
Froussios May 12, 2015
7ca227c
Added runnable examples chapter 1
Froussios May 12, 2015
172ebae
Added runnable examples: Chapter 2
Froussios May 12, 2015
6a32dea
Consistent example format
Froussios May 12, 2015
b6247fe
Consistent example format
Froussios May 12, 2015
5c2ed42
3.4 Added `ambWith` example
Froussios May 18, 2015
9bc2280
3.4 ambWith better style
Froussios May 18, 2015
b4380a6
3.4 Added `concatWith` example
Froussios May 18, 2015
b50059f
Exchanged names of mixed files
Froussios May 18, 2015
28a6e60
2.5 Added `concatMap`
Froussios May 18, 2015
e1a6eb2
2.5 Added `flatMapIterable` examples
Froussios May 18, 2015
bb0b9a5
3.2 Simplified forEach test
Froussios May 18, 2015
5e2efd0
3.4 Added `zipWith` examples
Froussios May 18, 2015
c41d565
3.4 Added more examples for `zip`
Froussios May 18, 2015
6102960
Removed unnecessary casts
Froussios May 21, 2015
5ef22e6
3.6 Added `cache` examples
Froussios May 21, 2015
73cbaf7
4.4 Added `doOnRequest` examples
Froussios May 21, 2015
761c8f6
3.4 Added `mergeDelayError` examples
Froussios May 21, 2015
06a4dca
3.4 Added `mergeWith` examples
Froussios May 21, 2015
23994c0
3.3 Added `retryWhen` example
Froussios May 21, 2015
df9320e
Removed warnings
Froussios May 21, 2015
c96f161
Fixed test for timer with repeat
Froussios May 22, 2015
238d568
Removed @Test from example
Froussios May 22, 2015
79c3aab
3.4 Added `switchMap` examples
Froussios May 22, 2015
f8ffe5d
3.4 `switchOnNext` example like `switchMap`
Froussios May 22, 2015
3fc5870
3.5 Added `takeLastBuffer` examples
Froussios May 22, 2015
ce282e3
3.5 Added `throttleWithTimeout` example
Froussios May 22, 2015
9c5c39e
2.1 Added from(future) examples
Froussios May 24, 2015
56351eb
2.4 Added `nest` examples
Froussios May 24, 2015
ad19801
4.1 Added `unsubscribeOn` examples
Froussios May 24, 2015
9fbaf84
3.7 Added `serialize` + `unsafeSubscribe` examples
Froussios May 25, 2015
668ec62
3.1 Added `asObservable` examples
Froussios May 25, 2015
c977a24
2.3 Simplified `defaultIfEmpty` example
Froussios Jun 10, 2015
bd5d9d5
Simplified `Map` example
Froussios Jun 11, 2015
c899fad
Modified `RetryWhen` to match book
Froussios Jun 11, 2015
7775f3c
Renamed examples classes to end in _Example
Froussios Jun 18, 2015
3cfa8d0
Merge remote-tracking branch 'origin/master' into Tests-and-examples
Froussios Jun 18, 2015
5078faf
1.2 Added `PublishSubject` example
Froussios Jun 18, 2015
08ee7bc
1.2 Typo in code
Froussios Jun 18, 2015
f6f6ca1
Linked to examples
Froussios Jun 18, 2015
509e193
Misformatted code
Froussios Jun 18, 2015
eb6d789
Linked to examples
Froussios Jun 18, 2015
269ec5e
Fixed broken links to examples
Froussios Jun 18, 2015
8467f04
Fixed output format
Froussios Jun 18, 2015
41c22d9
Linked to examples
Froussios Jun 18, 2015
0194a94
2.1 Added alternative Rx contract example
Froussios Jun 18, 2015
f800dc8
Fixed `defer` and `create` mix-up
Froussios Jun 18, 2015
e20335e
Linked to examples
Froussios Jun 18, 2015
ba26816
Linked to examples
Froussios Jun 18, 2015
61c9785
Linked to examples
Froussios Jun 18, 2015
ae26e15
Linked to examples
Froussios Jun 18, 2015
27777d5
Fixed indentation
Froussios Jun 18, 2015
026abd9
Linked to examples
Froussios Jun 18, 2015
c6092d9
Linked to examples
Froussios Jun 18, 2015
b3700d1
Linked to examples
Froussios Jun 18, 2015
a1299c2
Linked to examples
Froussios Jun 18, 2015
9f21f30
Linked examples
Froussios Jun 18, 2015
0702d8f
Linked to examples
Froussios Jun 18, 2015
6494b7d
Linked to examples
Froussios Jun 18, 2015
f533c04
Linked to examples
Froussios Jun 18, 2015
e18023a
typo
Froussios Jun 18, 2015
bc7b9be
Linked to examples
Froussios Jun 18, 2015
e330cbb
Linked to examples
Froussios Jun 18, 2015
899c1d2
Linked to examples
Froussios Jun 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions Part 1 - Getting Started/2. Key types.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void main(String[] args) {
subject.onNext(4);
}
```
Output
[Output](/tests/java/itrx/chapter1/PublishSubjectExample.java)
```
2
3
Expand All @@ -100,7 +100,7 @@ s.onNext(1);
s.subscribe(v -> System.out.println("Late: " + v));
s.onNext(2);
```
Output
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
```
Early:0
Early:1
Expand All @@ -122,8 +122,7 @@ s.onNext(2);
s.subscribe(v -> System.out.println("Late: " + v));
s.onNext(3);
```

Output
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
```
Late: 1
Late: 2
Expand All @@ -144,8 +143,7 @@ s.onNext(2);
s.subscribe(v -> System.out.println("Late: " + v));
s.onNext(3);
```

Output
[Output](/tests/java/itrx/chapter1/ReplaySubjectExample.java)
```
Late: 1
Late: 2
Expand All @@ -168,8 +166,7 @@ s.onNext(2);
s.subscribe(v -> System.out.println("Late: " + v));
s.onNext(3);
```

output
[Output](/tests/java/itrx/chapter1/BehaviorSubjectExample.java)
```
Late: 2
Late: 3
Expand Down Expand Up @@ -197,8 +194,7 @@ BehaviorSubject<Integer> s = BehaviorSubject.create(0);
s.subscribe(v -> System.out.println(v));
s.onNext(1);
```

Output
[Output](/tests/java/itrx/chapter1/BehaviorSubjectExample.java)
```
0
1
Expand All @@ -218,8 +214,7 @@ s.onNext(1);
s.onNext(2);
s.onCompleted();
```

Output
[Output](/tests/java/itrx/chapter1/AsyncSubjectExample.java)
```
2
```
Expand All @@ -238,7 +233,7 @@ s.onCompleted();
s.onNext(1);
s.onNext(2);
```
Output
[Output](/tests/java/itrx/chapter1/RxContractExample.java)
```
0
```
Expand Down
21 changes: 9 additions & 12 deletions Part 1 - Getting Started/3. Lifetime management.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Subscription subscribe(Observer<? super T> observer)
Subscription subscribe(Subscriber<? super T> subscriber)
```

`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.
`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.

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

```java
Subject<Integer, Integer> s = ReplaySubject.create();
s.subscribe(
v -> System.out.println(v),
e -> System.err.println(e));
v -> System.out.println(v),
e -> System.err.println(e));
s.onNext(0);
s.onError(new Exception("Oops"));
```
Expand Down Expand Up @@ -59,9 +59,8 @@ values.onNext(1);
subscription.unsubscribe();
values.onNext(2);
```

Output
```java
[Output](/tests/java/itrx/chapter1/UnsubscribingExample.java)
```
0
1
```
Expand All @@ -82,8 +81,7 @@ subscription1.unsubscribe();
System.out.println("Unsubscribed first");
values.onNext(2);
```

Output
[Output](/tests/java/itrx/chapter1/UnsubscribingExample.java)
```
First: 0
Second: 0
Expand All @@ -95,7 +93,7 @@ Second: 2

## onError and onCompleted

`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.
`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.

```java
Subject<Integer, Integer> values = ReplaySubject.create();
Expand All @@ -109,8 +107,7 @@ values.onNext(1);
values.onCompleted();
values.onNext(2);
```

Output
[Output](/tests/java/itrx/chapter1/RxContractExample.java)
```
First: 0
First: 1
Expand All @@ -125,7 +122,7 @@ A `Subscription` is tied to the resources it uses. For that reason, you should r
Subscription s = Subscriptions.create(() -> System.out.println("Clean"));
s.unsubscribe();
```
Output
[Output](/tests/java/itrx/chapter1/UnsubscribingExample.java)
```
Clean
```
Expand Down
32 changes: 13 additions & 19 deletions Part 2 - Sequence Basics/1. Creating a sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```

Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
Received: one
Received: two
Expand All @@ -41,8 +40,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```

Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
Completed
```
Expand All @@ -60,7 +58,7 @@ Subscription subscription = values.subscribe(
);
```

The above code will print nothing. Note that this doesn't mean that the program is blocking. In fact, it will terminate immediately.
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.

### Observable.error

Expand All @@ -74,8 +72,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```

Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
Error: java.lang.Exception: Oops
```
Expand All @@ -91,7 +88,7 @@ now.subscribe(System.out::println);
Thread.sleep(1000);
now.subscribe(System.out::println);
```
Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
1431443908375
1431443908375
Expand All @@ -107,7 +104,7 @@ now.subscribe(System.out::println);
Thread.sleep(1000);
now.subscribe(System.out::println);
```
Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
1431444107854
1431444108858
Expand All @@ -134,7 +131,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```
Output
[Output](/tests/java/itrx/chapter2/creating/ObservableFactoriesExample.java)
```
Received: Hello
Completed
Expand All @@ -160,7 +157,7 @@ A straight forward and familiar method to any functional programmer. It emits th
Observable<Integer> values = Observable.range(10, 15);
```

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

### Observable.interval

Expand All @@ -175,8 +172,7 @@ Subscription subscription = values.subscribe(
);
System.in.read();
```

Output
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
```
Received: 0
Received: 1
Expand All @@ -201,7 +197,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```
Output
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
```
Received: 0
Completed
Expand All @@ -217,7 +213,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```
output
[Output](/tests/java/itrx/chapter2/creating/FunctionalUnfoldsExample.java)
```
Received: 0
Received: 1
Expand Down Expand Up @@ -267,8 +263,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```

Output
[Output](/tests/java/itrx/chapter2/creating/FromExample.java)
```
Received: 21
Completed
Expand All @@ -293,8 +288,7 @@ Subscription subscription = values.subscribe(
() -> System.out.println("Completed")
);
```

Output
[Output](/tests/java/itrx/chapter2/creating/FromExample.java)
```
Received: 1
Received: 2
Expand Down
Loading
X Tutup