Skip to content

Commit df4d569

Browse files
Merge pull request #376 from samuelgruetter/idiomaticscala
Idiomatic Scala Adaptor
2 parents 4bda940 + 6072d65 commit df4d569

File tree

18 files changed

+2580
-13
lines changed

18 files changed

+2580
-13
lines changed
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: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
# Scala Adaptor for RxJava
22

3-
4-
This adaptor allows 'fn' functions to be used and RxJava will know how to invoke them.
5-
6-
This enables code such as:
7-
8-
```scala
9-
Observable.from("1", "2", "3")
10-
.take(2)
11-
.subscribe((callback: String) => {
12-
println(callback)
13-
})
14-
```
3+
There's an old Scala adaptor ( `rx.lang.scala.RxImplicits` with test `rx.lang.scala.RxImplicitsTest` ), which is deprecated. All other classes in `rx.lang.scala` belong to the new adaptor.
154

165
# Binaries
176

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
- [ ] ConnectableObservable: Implement adaptor. Note that it cannot extend Scala Observable, since value classes are final.
8+
- [ ] more methods of BlockingObservable
9+
- [ ] multicast, publish, replay once we have ConnectableObservable
10+
- [ ] groupBy and GroupedObservable
11+
- [ ] mirror complete Java package structure in Scala
12+
- [ ] convert Java futures to Scala futures
13+
- [ ] Add methods present in Scala collections library, but not in RxJava, e.g. zipWithIndex, aggregate à la Scala
14+
- [ ] mergeDelayError, combineLatest, merge, concat, zip: decide if instance method or static or both, decide about arities > 2
15+
- [ ] naming: switch() or switchOnNext()?
16+
- [ ] decide where the MovieLib/MovieLibUsage (use Scala code from Java code) example should live and make sure gradle builds it in the right order
17+
- [ ] Avoid text duplication in scaladoc using templates, add examples, distinction between use case signature and full signature
18+
- [ ] other small TODOs
19+
20+

0 commit comments

Comments
 (0)