From 19b41bf1e6eca445304b2cc2cc601469ca609318 Mon Sep 17 00:00:00 2001 From: kranthik2 Date: Mon, 25 May 2020 11:50:03 -0500 Subject: [PATCH 1/2] Fixed image link and added java examples --- docs/Connectable-Observable-Operators.md | 47 +++++++++++------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/docs/Connectable-Observable-Operators.md b/docs/Connectable-Observable-Operators.md index 582f0fac12..157ded821b 100644 --- a/docs/Connectable-Observable-Operators.md +++ b/docs/Connectable-Observable-Operators.md @@ -7,25 +7,22 @@ This section explains the [`ConnectableObservable`](http://reactivex.io/RxJava/j A Connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its `connect()` method is called. In this way you can wait for all intended Subscribers to subscribe to the Observable before the Observable begins emitting items. - + The following example code shows two Subscribers subscribing to the same Observable. In the first case, they subscribe to an ordinary Observable; in the second case, they subscribe to a Connectable Observable that only connects after both Subscribers subscribe. Note the difference in the output: **Example #1:** -```groovy -def firstMillion = Observable.range( 1, 1000000 ).sample(7, java.util.concurrent.TimeUnit.MILLISECONDS); +```java +Observable firstMillion = Observable.range(1, 1000000).sample(7, java.util.concurrent.TimeUnit.MILLISECONDS); -firstMillion.subscribe( - { println("Subscriber #1:" + it); }, // onNext - { println("Error: " + it.getMessage()); }, // onError - { println("Sequence #1 complete"); } // onCompleted -); - -firstMillion.subscribe( - { println("Subscriber #2:" + it); }, // onNext - { println("Error: " + it.getMessage()); }, // onError - { println("Sequence #2 complete"); } // onCompleted -); +firstMillion.subscribe(next -> System.out.println("Subscriber #1: " + next), // onNext + throwable -> System.out.println("Error: " + throwable), // onError + () -> System.out.println("Sequence #1 complete") // onComplete + ); +firstMillion.subscribe(next -> System.out.println("Subscriber #2: " + next), // onNext + throwable -> System.out.println("Error: " + throwable), // onError + () -> System.out.println("Sequence #2 complete") // onComplete + ); ``` ``` Subscriber #1:211128 @@ -40,20 +37,18 @@ Subscriber #2:826996 Sequence #2 complete ``` **Example #2:** -```groovy -def firstMillion = Observable.range( 1, 1000000 ).sample(7, java.util.concurrent.TimeUnit.MILLISECONDS).publish(); +```java +ConnectableObservable firstMillion = Observable.range(1, 1000000).sample(7, java.util.concurrent.TimeUnit.MILLISECONDS).publish(); -firstMillion.subscribe( - { println("Subscriber #1:" + it); }, // onNext - { println("Error: " + it.getMessage()); }, // onError - { println("Sequence #1 complete"); } // onCompleted -); +firstMillion.subscribe(next -> System.out.println("Subscriber #1: " + next), // onNext + throwable -> System.out.println("Error: " + throwable), // onError + () -> System.out.println("Sequence #1 complete") // onComplete + ); -firstMillion.subscribe( - { println("Subscriber #2:" + it); }, // onNext - { println("Error: " + it.getMessage()); }, // onError - { println("Sequence #2 complete"); } // onCompleted -); +firstMillion.subscribe(next -> System.out.println("Subscriber #2: " + next), // onNext + throwable -> System.out.println("Error: " + throwable), // onError + () -> System.out.println("Sequence #2 complete") // onComplete + ); firstMillion.connect(); ``` From 8cf1f164456085a266766373874cef45551610db Mon Sep 17 00:00:00 2001 From: kranthik2 Date: Mon, 25 May 2020 22:58:15 -0500 Subject: [PATCH 2/2] 3.x:Update Getting started docs --- docs/Getting-Started.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/Getting-Started.md b/docs/Getting-Started.md index fb9baa47dd..e3453fbc28 100644 --- a/docs/Getting-Started.md +++ b/docs/Getting-Started.md @@ -1,20 +1,20 @@ ## Getting Binaries -You can find binaries and dependency information for Maven, Ivy, Gradle, SBT, and others at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cg%3A"io.reactivex.rxjava2"%20AND%20"rxjava2"). +You can find binaries and dependency information for Maven, Ivy, Gradle, SBT, and others at [http://search.maven.org](https://search.maven.org/search?q=g:io.reactivex.rxjava3%20AND%20rxjava). Example for Maven: ```xml - io.reactivex.rxjava2 + io.reactivex.rxjava3 rxjava - 2.2.0 + 3.0.4 ``` and for Ivy: ```xml - + ``` and for SBT: @@ -22,12 +22,12 @@ and for SBT: ```scala libraryDependencies += "io.reactivex" %% "rxscala" % "0.26.5" -libraryDependencies += "io.reactivex.rxjava2" % "rxjava" % "2.2.0" +libraryDependencies += "io.reactivex.rxjava3" % "rxjava" % "3.0.4" ``` and for Gradle: ```groovy -compile 'io.reactivex.rxjava2:rxjava:2.2.0' +compile 'io.reactivex.rxjava3:rxjava:3.0.4' ``` If you need to download the jars instead of using a build system, create a Maven `pom` file like this with the desired version: @@ -38,17 +38,17 @@ If you need to download the jars instead of using a build system, create a Maven xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.reactivex.rxjava2 + io.reactivex.rxjava3 rxjava - 2.2.0 + 3.0.4 RxJava Reactive Extensions for Java https://github.com/ReactiveX/RxJava - io.reactivex.rxjava2 + io.reactivex.rxjava3 rxjava - 2.2.0 + 3.0.4 @@ -66,7 +66,7 @@ You need Java 6 or later. ### Snapshots -Snapshots are available via [JFrog](https://oss.jfrog.org/libs-snapshot/io/reactivex/rxjava2/rxjava/): +Snapshots are available via [JFrog](https://oss.jfrog.org/libs-snapshot/io/reactivex/rxjava3/rxjava/): ```groovy repositories { @@ -74,7 +74,7 @@ repositories { } dependencies { - compile 'io.reactivex.rxjava2:rxjava:2.2.0-SNAPSHOT' + compile 'io.reactivex.rxjava3:rxjava:3.0.4' } ```