-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idiomatic Scala Adaptor #376
Merged
benjchristensen
merged 38 commits into
ReactiveX:master
from
samuelgruetter:idiomaticscala
Sep 13, 2013
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c159625
set up stubs for Scala Observable and its testing
samuelgruetter aa3ae12
add methods to Scala Wrapper (1)
samuelgruetter cce3ac1
add methods to Scala Wrapper (2) and find scalac bug
samuelgruetter 25c4642
work around scalac bug by removing `extends AnyVal`
samuelgruetter 0df8170
work around scalac bug by giving explicit type parameter to Observabl…
samuelgruetter 61abf29
add methods to Scala Wrapper (3) and find interesting questions
samuelgruetter 7872df8
add methods to Scala Wrapper (4)
samuelgruetter 81584d0
Merge branch 'master' of github.com:Netflix/RxJava into idiomaticscala
samuelgruetter 955fbfc
add methods to Scala Wrapper (5) (window)
samuelgruetter 6f58752
add Observer wrapper to make subscribe(Observer[T]) work
samuelgruetter 1c9ddef
Merge branch 'master' of github.com:Netflix/RxJava into idiomaticscala
samuelgruetter e3f3ba7
get rid of wrapper around Observer
samuelgruetter 72c0e8a
add methods to Scala Wrapper (6)
samuelgruetter dd591b8
make dematerialize infer everything
samuelgruetter 1caee60
add methods to Scala Wrapper (7)
samuelgruetter d12eb25
(does not compile!) refactoring of package structure
samuelgruetter dbf0375
refactoring package structure
samuelgruetter 0603e39
Java example using Scala Observable code
samuelgruetter 0566f9c
IntervalDemo
samuelgruetter 61c2218
add usability tests
samuelgruetter 2901c06
add operation merge (as instance method)
samuelgruetter 171131c
add a int-version of buffer and window...
samuelgruetter 2bf40bc
Merge branch 'master' of github.com:Netflix/RxJava into idiomaticscala
samuelgruetter c9f60ee
replace cast in window() by ascription
samuelgruetter f8787aa
Merge branch 'master' of github.com:Netflix/RxJava into idiomaticscala
samuelgruetter 0a9c485
fix reduce to work with new no-wildcards Java reduce
samuelgruetter 05a79a8
add debounce/throttle methods
samuelgruetter d0a48b2
refactor package structure
samuelgruetter f0feb97
remove sleep() from RxScalaDemo
samuelgruetter 54fc958
BlockingObservable: add foreach and make it extend AnyVal
samuelgruetter 4788a22
add apply() which takes Java Observable
samuelgruetter 1bec926
restore old RxImplicits and RxImplicitsTests
samuelgruetter 1d52491
mark RxImplicits and RxImplicitsTests as old
samuelgruetter 2bd12ab
complete WithFilter
samuelgruetter 4915348
TODO list for Scala adaptor
samuelgruetter 6633ac9
update README
samuelgruetter 0ad4282
add more methods and type aliases
samuelgruetter 6072d65
add license headers
samuelgruetter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuelgruetter Do you want this separate project being published to Maven Central? Does this code need to be a separate project or can it go under ./src/examples/ like each of the other language adaptors? As a full module it gets built and published.
Here are how the examples are placed for Clojure and Groovy:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this not yet the way it should be. This
rxjava-scala-java
project only containsMovieLibUsage.java
, which illustrates that Scala code using Scala Observables can be used from Java with Java Observables.MovieLibUsage.java
should reside somewhere inrxjava-scala/src/examples
, and should be compiled by the Java compiler, but only after the Scala compiler has compiledMovieLib.scala
. Since I have no experience with gradle, the only way I could solve this was to make a seperate project forMovieLibUsage.java
which depends on the project containingMovieLib.scala
.Another solution that I found would be to instruct the Scala compiler to compile
MovieLibUsage.java
, too, but I don't like this solution, because I'd like to illustrate with this example that Java code depending on Scala libraries using Scala Observables can be built using the Java compiler having Scala-generated class files on the classpath.I'd be very happy if you could set up the gradle build such that this works.