Skip to content

Commit 59dc7a3

Browse files
authored
Fix grammar, add imports to some examples.
1 parent 2d6a39c commit 59dc7a3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class HelloWorld {
5656
If your platform doesn't support Java 8 lambdas (yet), you have to create an inner class of `Consumer` manually:
5757

5858
```java
59+
import io.reactivex.functions.Consumer;
60+
5961
Flowable.just("Hello world")
6062
.subscribe(new Consumer<String>() {
6163
@Override public void accept(String s) {
@@ -75,6 +77,8 @@ RxJava 2 features several base classes you can discover operators on:
7577
One of the common use cases for RxJava is to run some computation, network request on a background thread and show the results (or error) on the UI thread:
7678

7779
```java
80+
import io.reactivex.schedulers.Schedulers;
81+
7882
Flowable.fromCallable(() -> {
7983
Thread.sleep(1000); // imitate expensive computation
8084
return "Done";
@@ -105,7 +109,7 @@ Thread.sleep(2000);
105109
106110
Typically, you can move computations or blocking IO to some other thread via `subscribeOn`. Once the data is ready, you can make sure they get processed on the foreground or GUI thread via `observeOn`.
107111
108-
RxJava operators don't work `Thread`s or `ExecutorService`s directly but with so called `Scheduler`s that abstract away sources of concurrency behind an uniform API. RxJava 2 features several standard schedulers accessible via `Schedulers` utility class. These are available on all JVM platforms but some specific platforms, such as Android, have their own typical `Scheduler`s defined: `AndroidSchedulers.mainThread()`, `SwingScheduler.instance()` or `JavaFXSchedulers.gui()`.
112+
RxJava operators don't work with `Thread`s or `ExecutorService`s directly but with so called `Scheduler`s that abstract away sources of concurrency behind an uniform API. RxJava 2 features several standard schedulers accessible via `Schedulers` utility class. These are available on all JVM platforms but some specific platforms, such as Android, have their own typical `Scheduler`s defined: `AndroidSchedulers.mainThread()`, `SwingScheduler.instance()` or `JavaFXSchedulers.gui()`.
109113

110114
The `Thread.sleep(2000);` at the end is no accident. In RxJava the default `Scheduler`s run on daemon threads, which means once the Java main thread exits, they all get stopped and background computations may never happen. Sleeping for some time in this example situations let's you see the output of the flow on the console with time to spare.
111115

0 commit comments

Comments
 (0)