|
1 | 1 | package com.baelding.rxjava; |
2 | 2 |
|
3 | | - |
4 | 3 | import rx.Observable; |
5 | | -import rx.Subscriber; |
6 | 4 | import rx.schedulers.Schedulers; |
7 | 5 |
|
8 | | -public class ColdObservableBackPressure { |
| 6 | +public class ColdObservableBackpressure { |
9 | 7 | public static void main(String[] args) throws InterruptedException { |
10 | | - Observable.range(1, 1_000_000) |
11 | | - .observeOn(Schedulers.computation()) |
12 | | - .subscribe(v -> ComputeFunction.compute(v), Throwable::printStackTrace); |
| 8 | + Observable.range(1, 1_000_000).observeOn(Schedulers.computation()).subscribe(v -> ComputeFunction.compute(v), Throwable::printStackTrace); |
13 | 9 |
|
14 | 10 | Thread.sleep(10_000); |
15 | 11 |
|
16 | | - |
17 | | -// Observable.range(1, 1_000_000) //implementation of reactive pull backpressure on cold observable |
18 | | -// .subscribe(new Subscriber<Integer>() { |
19 | | -// @Override |
20 | | -// public void onStart() { |
21 | | -// request(1); |
22 | | -// } |
23 | | -// |
24 | | -// public void onNext(Integer v) { |
25 | | -// compute(v); |
26 | | -// |
27 | | -// request(1); |
28 | | -// } |
29 | | -// |
30 | | -// @Override |
31 | | -// public void onError(Throwable ex) { |
32 | | -// ex.printStackTrace(); |
33 | | -// } |
34 | | -// |
35 | | -// @Override |
36 | | -// public void onCompleted() { |
37 | | -// System.out.println("Done!"); |
38 | | -// } |
39 | | -// }); |
| 12 | + // Observable.range(1, 1_000_000) //implementation of reactive pull backpressure on cold observable |
| 13 | + // .subscribe(new Subscriber<Integer>() { |
| 14 | + // @Override |
| 15 | + // public void onStart() { |
| 16 | + // request(1); |
| 17 | + // } |
| 18 | + // |
| 19 | + // public void onNext(Integer v) { |
| 20 | + // compute(v); |
| 21 | + // |
| 22 | + // request(1); |
| 23 | + // } |
| 24 | + // |
| 25 | + // @Override |
| 26 | + // public void onError(Throwable ex) { |
| 27 | + // ex.printStackTrace(); |
| 28 | + // } |
| 29 | + // |
| 30 | + // @Override |
| 31 | + // public void onCompleted() { |
| 32 | + // System.out.println("Done!"); |
| 33 | + // } |
| 34 | + // }); |
40 | 35 |
|
41 | 36 | } |
42 | 37 |
|
43 | | - |
44 | 38 | } |
0 commit comments