Skip to content

Commit bc7361f

Browse files
committed
Merge branch 'master' of github.com:Netflix/RxJava
2 parents b407e6e + fa72a27 commit bc7361f

File tree

76 files changed

+7927
-871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7927
-871
lines changed

CHANGES.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,69 @@
11
# RxJava Releases #
22

3+
### Version 0.14.1 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.14.1%22)) ###
4+
5+
* [Pull 402](https://github.com/Netflix/RxJava/pull/402) rxjava-apache-http improvements
6+
7+
### Version 0.14.0 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.14.0%22)) ###
8+
9+
Further progress to the Scala adaptor and a handful of new operators.
10+
11+
Bump to 0.14.0 due to small breaking change to `distinct` operator removing overloaded methods with `Comparator`. These methods were added in 0.13.2 and determined to be incorrect.
12+
13+
This release also includes a new contrib module, [rxjava-apache-http](https://github.com/Netflix/RxJava/tree/master/rxjava-contrib/rxjava-apache-http) that provides an Observable API to the Apache HttpAsyncClient.
14+
15+
* [Pull 396](https://github.com/Netflix/RxJava/pull/396) Add missing methods to Scala Adaptor
16+
* [Pull 390](https://github.com/Netflix/RxJava/pull/390) Operators: ElementAt and ElementAtOrDefault
17+
* [Pull 398](https://github.com/Netflix/RxJava/pull/398) Operators: IsEmpty and Exists (instead of Any)
18+
* [Pull 397](https://github.com/Netflix/RxJava/pull/397) Observable API for Apache HttpAsyncClient 4.0
19+
* [Pull 400](https://github.com/Netflix/RxJava/pull/400) Removing `comparator` overloads of `distinct`
20+
21+
### Version 0.13.5
22+
23+
* Upload to Sonatype failed so version skipped
24+
25+
### Version 0.13.4 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.13.4%22)) ###
26+
27+
* [Pull 393](https://github.com/Netflix/RxJava/pull/393) Parallel Operator & ObserveOn/ScheduledObserver Fixes
28+
* [Pull 394](https://github.com/Netflix/RxJava/pull/394) Change Interval and Sample default Scheduler
29+
* [Pull 391](https://github.com/Netflix/RxJava/pull/391) Fix OSGI support for rxjava-scala
30+
31+
### Version 0.13.3
32+
33+
* Upload to Sonatype failed so version skipped
34+
35+
### Version 0.13.2 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.13.2%22)) ###
36+
37+
* [Pull 389](https://github.com/Netflix/RxJava/pull/389) Scala Adaptor Improvements
38+
* [Pull 382](https://github.com/Netflix/RxJava/pull/382) Removing deprecated RxImplicits from rxjava-scala
39+
* [Pull 381](https://github.com/Netflix/RxJava/pull/381) Operator: mapWithIndex
40+
* [Pull 380](https://github.com/Netflix/RxJava/pull/380) Implemented `distinct` and `distinctUntilChanged` variants using a comparator
41+
* [Pull 379](https://github.com/Netflix/RxJava/pull/379) Make `interval` work with multiple subscribers
42+
43+
### Version 0.13.1 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.13.1%22)) ###
44+
45+
This release includes a new Scala adaptor as part of the effort from issue https://github.com/Netflix/RxJava/issues/336 pursuing idiomatic Scala support.
46+
47+
* [Pull 376](https://github.com/Netflix/RxJava/pull/376) Idiomatic Scala Adaptor
48+
* [Pull 375](https://github.com/Netflix/RxJava/pull/375) Operator: Distinct
49+
* [Pull 374](https://github.com/Netflix/RxJava/pull/374) Operator: DistinctUntilChanged
50+
* [Pull 373](https://github.com/Netflix/RxJava/pull/373) Fixes and Cleanup
51+
52+
### Version 0.13.0 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.13.0%22)) ###
53+
54+
This release has some minor changes related to varargs that could break backwards compatibility
55+
if directly passing arrays but for most this release should not be breaking.
56+
57+
* [Pull 354](https://github.com/Netflix/RxJava/pull/354) Operators: Count, Sum, Average
58+
* [Pull 355](https://github.com/Netflix/RxJava/pull/355) Operators: skipWhile and skipWhileWithIndex
59+
* [Pull 356](https://github.com/Netflix/RxJava/pull/356) Operator: Interval
60+
* [Pull 357](https://github.com/Netflix/RxJava/pull/357) Operators: first and firstOrDefault
61+
* [Pull 368](https://github.com/Netflix/RxJava/pull/368) Operators: Throttle and Debounce
62+
* [Pull 371](https://github.com/Netflix/RxJava/pull/371) Operator: Retry
63+
* [Pull 370](https://github.com/Netflix/RxJava/pull/370) Change zip method signature from Collection to Iterable
64+
* [Pull 369](https://github.com/Netflix/RxJava/pull/369) Generics Improvements: co/contra-variance
65+
* [Pull 361](https://github.com/Netflix/RxJava/pull/361) Remove use of varargs from API
66+
367
### Version 0.12.2 ([Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20v%3A%220.12.2%22)) ###
468

569
* [Pull 352](https://github.com/Netflix/RxJava/pull/352) Groovy Language Adaptor: Add Func5-9 and N to the wrapper

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.12.3-SNAPSHOT
1+
version=0.14.2-SNAPSHOT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package rx.lang.groovy
2+
3+
import org.junit.Test
4+
5+
import rx.Observable
6+
import rx.Scheduler
7+
import rx.concurrency.Schedulers
8+
import rx.util.functions.Func1
9+
10+
class TestParallel {
11+
12+
@Test
13+
public void testParallelOperator() {
14+
Observable.range(0, 100)
15+
.parallel({
16+
it.map({ return it; })
17+
})
18+
.toBlockingObservable()
19+
.forEach({ println("T: " + it + " Thread: " + Thread.currentThread()); });
20+
}
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
rxjava-scala-java
3+
-----------------
4+
5+
Contains examples illustrating how RxScala code can be used from Java.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
apply plugin: 'osgi'
3+
4+
5+
project(':language-adaptors:rxjava-scala-java') {
6+
//sourceSets.test.java.srcDir 'src/examples/java'
7+
sourceSets.main.java.srcDir 'src/main/java'
8+
}
9+
10+
dependencies {
11+
compile 'org.scala-lang:scala-library:2.10.+'
12+
13+
compile project(':rxjava-core')
14+
15+
compile project(':language-adaptors:rxjava-scala')
16+
17+
provided 'junit:junit-dep:4.10'
18+
provided 'org.mockito:mockito-core:1.8.5'
19+
provided 'org.scalatest:scalatest_2.10:1.9.1'
20+
}
21+
22+
jar {
23+
manifest {
24+
name = 'rxjava-scala-java'
25+
instruction 'Bundle-Vendor', 'Netflix'
26+
instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava'
27+
instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*'
28+
instruction 'Fragment-Host', 'com.netflix.rxjava.core'
29+
}
30+
}
31+
32+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package rx.lang.scala.examples;
2+
3+
import org.junit.Test;
4+
5+
import rx.Observable;
6+
import rx.util.functions.Action1;
7+
8+
9+
public class MovieLibUsage {
10+
11+
Action1<Movie> moviePrinter = new Action1<Movie>() {
12+
public void call(Movie m) {
13+
System.out.println("A movie of length " + m.lengthInSeconds() + "s");
14+
}
15+
};
16+
17+
@Test
18+
public void test() {
19+
MovieLib lib = new MovieLib(Observable.from(new Movie(3000), new Movie(1000), new Movie(2000)));
20+
21+
lib.longMovies().subscribe(moviePrinter);
22+
}
23+
24+
}

language-adaptors/rxjava-scala/README.md

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,71 @@
11
# Scala Adaptor for RxJava
22

3+
This adaptor allows to use RxJava in Scala with anonymous functions, e.g.
34

4-
This adaptor allows 'fn' functions to be used and RxJava will know how to invoke them.
5+
```scala
6+
val o = Observable.interval(200 millis).take(5)
7+
o.subscribe(n => println("n = " + n))
8+
Observable(1, 2, 3, 4).reduce(_ + _)
9+
```
10+
11+
For-comprehensions are also supported:
12+
13+
```scala
14+
val first = Observable(10, 11, 12)
15+
val second = Observable(10, 11, 12)
16+
val booleans = for ((n1, n2) <- (first zip second)) yield (n1 == n2)
17+
```
518

6-
This enables code such as:
19+
Further, this adaptor attempts to expose an API which is as Scala-idiomatic as possible. This means that certain methods have been renamed, their signature was changed, or static methods were changed to instance methods. Some examples:
720

821
```scala
9-
Observable.from("1", "2", "3")
10-
.take(2)
11-
.subscribe((callback: String) => {
12-
println(callback)
13-
})
22+
// instead of concat:
23+
def ++[U >: T](that: Observable[U]): Observable[U]
24+
25+
// instance method instead of static:
26+
def zip[U](that: Observable[U]): Observable[(T, U)]
27+
28+
// the implicit evidence argument ensures that dematerialize can only be called on Observables of Notifications:
29+
def dematerialize[U](implicit evidence: T <:< Notification[U]): Observable[U]
30+
31+
// additional type parameter U with lower bound to get covariance right:
32+
def onErrorResumeNext[U >: T](resumeFunction: Throwable => Observable[U]): Observable[U]
33+
34+
// curried in Scala collections, so curry fold also here:
35+
def fold[R](initialValue: R)(accumulator: (R, T) => R): Observable[R]
36+
37+
// using Duration instead of (long timepan, TimeUnit duration):
38+
def sample(duration: Duration): Observable[T]
39+
40+
// called skip in Java, but drop in Scala
41+
def drop(n: Int): Observable[T]
42+
43+
// there's only mapWithIndex in Java, because Java doesn't have tuples:
44+
def zipWithIndex: Observable[(T, Int)]
45+
46+
// corresponds to Java's toList:
47+
def toSeq: Observable[Seq[T]]
48+
49+
// the implicit evidence argument ensures that switch can only be called on Observables of Observables:
50+
def switch[U](implicit evidence: Observable[T] <:< Observable[Observable[U]]): Observable[U]
51+
52+
// Java's from becomes apply, and we use Scala Range
53+
def apply(range: Range): Observable[Int]
54+
55+
// use Bottom type:
56+
def never: Observable[Nothing]
1457
```
1558

16-
# Binaries
59+
Also, the Scala Observable is fully covariant in its type parameter, whereas the Java Observable only achieves partial covariance due to limitations of Java's type system (or if you can fix this, your suggestions are very welcome).
60+
61+
For more examples, see [RxScalaDemo.scala](https://github.com/Netflix/RxJava/blob/master/language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/examples/RxScalaDemo.scala).
62+
63+
Scala code using Rx should only import members from `rx.lang.scala` and below.
64+
65+
Work on this adaptor is still in progress, and for the moment, the best source of documentation are the comments in the source code of [`rx.lang.scala.Observable`](https://github.com/Netflix/RxJava/blob/master/language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala).
66+
67+
68+
## Binaries
1769

1870
Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22rxjava-scala%22).
1971

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
TODOs for Scala Adapter
3+
-----------------------
4+
5+
This is a (probably incomplete) list of what still needs to be done in the Scala adaptor:
6+
7+
* mirror complete Java package structure in Scala
8+
* objects for classes with static methods or singletons (e.g. Schedulers, Subscriptions)
9+
* Notification as a case class
10+
* integrating Scala Futures, should there be a common base interface for Futures and Observables?
11+
* Add methods present in Scala collections library, but not in RxJava, e.g. aggregate à la Scala, collect, exists, tails, ...
12+
* combineLatest with arities > 2
13+
* decide where the MovieLib/MovieLibUsage (use Scala code from Java code) example should live and make sure gradle builds it in the right order
14+
* Avoid text duplication in scaladoc using templates, add examples, distinction between use case signature and full signature
15+
* other small TODOs
16+
17+

language-adaptors/rxjava-scala/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jar {
4949
name = 'rxjava-scala'
5050
instruction 'Bundle-Vendor', 'Netflix'
5151
instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava'
52-
instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*'
52+
instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,!org.scalatest.*,*'
5353
instruction 'Fragment-Host', 'com.netflix.rxjava.core'
5454
}
5555
}

0 commit comments

Comments
 (0)