Skip to content

Commit

Permalink
Merge pull request #376 from samuelgruetter/idiomaticscala
Browse files Browse the repository at this point in the history
Idiomatic Scala Adaptor
  • Loading branch information
benjchristensen committed Sep 13, 2013
2 parents 4bda940 + 6072d65 commit df4d569
Show file tree
Hide file tree
Showing 18 changed files with 2,580 additions and 13 deletions.
5 changes: 5 additions & 0 deletions language-adaptors/rxjava-scala-java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

rxjava-scala-java
-----------------

Contains examples illustrating how RxScala code can be used from Java.
32 changes: 32 additions & 0 deletions language-adaptors/rxjava-scala-java/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

apply plugin: 'osgi'


project(':language-adaptors:rxjava-scala-java') {
//sourceSets.test.java.srcDir 'src/examples/java'
sourceSets.main.java.srcDir 'src/main/java'
}

dependencies {
compile 'org.scala-lang:scala-library:2.10.+'

compile project(':rxjava-core')

compile project(':language-adaptors:rxjava-scala')

provided 'junit:junit-dep:4.10'
provided 'org.mockito:mockito-core:1.8.5'
provided 'org.scalatest:scalatest_2.10:1.9.1'
}

jar {
manifest {
name = 'rxjava-scala-java'
instruction 'Bundle-Vendor', 'Netflix'
instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava'
instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*'
instruction 'Fragment-Host', 'com.netflix.rxjava.core'
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package rx.lang.scala.examples;

import org.junit.Test;

import rx.Observable;
import rx.util.functions.Action1;


public class MovieLibUsage {

Action1<Movie> moviePrinter = new Action1<Movie>() {
public void call(Movie m) {
System.out.println("A movie of length " + m.lengthInSeconds() + "s");
}
};

@Test
public void test() {
MovieLib lib = new MovieLib(Observable.from(new Movie(3000), new Movie(1000), new Movie(2000)));

lib.longMovies().subscribe(moviePrinter);
}

}
13 changes: 1 addition & 12 deletions language-adaptors/rxjava-scala/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# Scala Adaptor for RxJava


This adaptor allows 'fn' functions to be used and RxJava will know how to invoke them.

This enables code such as:

```scala
Observable.from("1", "2", "3")
.take(2)
.subscribe((callback: String) => {
println(callback)
})
```
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.

# Binaries

Expand Down
20 changes: 20 additions & 0 deletions language-adaptors/rxjava-scala/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

TODOs for Scala Adapter
-----------------------

This is a (probably incomplete) list of what still needs to be done in the Scala adaptor:

- [ ] ConnectableObservable: Implement adaptor. Note that it cannot extend Scala Observable, since value classes are final.
- [ ] more methods of BlockingObservable
- [ ] multicast, publish, replay once we have ConnectableObservable
- [ ] groupBy and GroupedObservable
- [ ] mirror complete Java package structure in Scala
- [ ] convert Java futures to Scala futures
- [ ] Add methods present in Scala collections library, but not in RxJava, e.g. zipWithIndex, aggregate à la Scala
- [ ] mergeDelayError, combineLatest, merge, concat, zip: decide if instance method or static or both, decide about arities > 2
- [ ] naming: switch() or switchOnNext()?
- [ ] decide where the MovieLib/MovieLibUsage (use Scala code from Java code) example should live and make sure gradle builds it in the right order
- [ ] Avoid text duplication in scaladoc using templates, add examples, distinction between use case signature and full signature
- [ ] other small TODOs


Loading

0 comments on commit df4d569

Please sign in to comment.