forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ReactiveX#376 from samuelgruetter/idiomaticscala
Idiomatic Scala Adaptor
- Loading branch information
Showing
18 changed files
with
2,580 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
language-adaptors/rxjava-scala-java/src/main/java/rx/lang/scala/examples/MovieLibUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
Oops, something went wrong.