Skip to content

Commit

Permalink
Update outdated java example in wiki #6331 (#6351)
Browse files Browse the repository at this point in the history
* Update outdated java example in wiki #6331

* update wiki page similar to README

* keep the original example
  • Loading branch information
ozcanyus authored and akarnokd committed Dec 28, 2018
1 parent 5aef7fe commit 4f0cdca
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions docs/How-To-Use-RxJava.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ You can find additional code examples in the `/src/examples` folders of each [la
### Java

```java
public static void hello(String... names) {
Observable.from(names).subscribe(new Action1<String>() {

@Override
public void call(String s) {
System.out.println("Hello " + s + "!");
}
public static void hello(String... args) {
Flowable.fromArray(args).subscribe(s -> System.out.println("Hello " + s + "!"));
}
```

});
If your platform doesn't support Java 8 lambdas (yet), you have to create an inner class of ```Consumer``` manually:
```java
public static void hello(String... args) {
Flowable.fromArray(args).subscribe(new Consumer<String>() {
@Override
public void accept(String s) {
System.out.println("Hello " + s + "!");
}
});
}
```

Expand Down Expand Up @@ -397,4 +402,4 @@ myModifiedObservable = myObservable.onErrorResumeNext({ t ->
Throwable myThrowable = myCustomizedThrowableCreator(t);
return (Observable.error(myThrowable));
});
```
```

0 comments on commit 4f0cdca

Please sign in to comment.