Skip to content
benjchristensen edited this page Mar 22, 2013 · 8 revisions

Getting Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Example for Maven:

<dependency>
    <groupId>com.netflix.rxjava</groupId>
    <artifactId>rxjava-core</artifactId>
    <version>0.5.0</version>
</dependency>

and for Ivy:

<dependency org="com.netflix.rxjava" name="rxjava-core" rev="0.5.0" />

If you need to download the jars instead of using a build system, create a Maven pom file like this with the desired version:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.netflix.rxjava.download</groupId>
	<artifactId>rxjava-download</artifactId>
	<version>1.0-SNAPSHOT</version>
	<name>Simple POM to download rxjava-core and dependencies</name>
	<url>http://github.com/Netflix/RxJava</url>
	<dependencies>
		<dependency>
			<groupId>com.netflix.rxjava</groupId>
			<artifactId>rxjava-core</artifactId>
			<version>0.5.0</version>
			<scope/>
		</dependency>
	</dependencies>
</project>

Then execute:

mvn -f download-rxjava-pom.xml dependency:copy-dependencies

It will download rxjava-core-*.jar and its dependencies into ./target/dependency/.

You need Java 6 or later.

Hello World!

The simplest use of RxJava is as follows:

In Java =>

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

            @Override
            public void call(String s) {
                System.out.println("Hello " + s + "!");
            }

        });
    }

In Groovy =>

def hello(String[] names) {
    Observable.toObservable(names)
        .subscribe({ println "Hello " + it + "!"})
}

In Clojure =>

(defn hello
  [&rest]
  (-> (Observable/toObservable &rest)
    (.subscribe #(println (str "Hello " % "!")))))

More examples and information can be found in the How To Use section.

Example source code can be found in the rxjava-examples module.

Building

To checkout the source and build:

$ git clone [email protected]:Netflix/RxJava.git
$ cd RxJava/
$ ./gradlew build

To do a clean build:

$ ./gradlew clean build

A build should look similar to this:

$ ./gradlew build
:rxjava-core:compileJava
:rxjava-core:processResources UP-TO-DATE
:rxjava-core:classes
:rxjava-core:jar
:rxjava-core:sourcesJar
:rxjava-core:signArchives SKIPPED
:rxjava-core:assemble
:rxjava-core:licenseMain UP-TO-DATE
:rxjava-core:licenseTest UP-TO-DATE
:rxjava-core:compileTestJava
:rxjava-core:processTestResources UP-TO-DATE
:rxjava-core:testClasses
:rxjava-core:test
:rxjava-core:check
:rxjava-core:build

BUILD SUCCESSFUL

Total time: 30.758 secs

On a clean build you will see the unit tests be run and look something like this:

> Building > :rxjava-core:test > 91 tests completed

sidebar

Clone this wiki locally