From 068f54739b1917893baf3d7db38ca8d8d37e256a Mon Sep 17 00:00:00 2001 From: Herman Banken Date: Sat, 30 May 2015 19:14:35 +0200 Subject: [PATCH 1/2] Move examples to remove access to private rx.lang.scala * Move examples * Fix small missing java conversion in scaladoc --- .../java/{rx/lang/scala => }/examples/MovieLibUsage.java | 4 +--- .../scala/{rx/lang/scala => }/examples/APICoverage.scala | 2 +- .../lang/scala => }/examples/ExperimentalAPIExamples.scala | 2 +- .../test/scala/{rx/lang/scala => }/examples/MovieLib.scala | 2 +- .../test/scala/{rx/lang/scala => }/examples/Olympics.scala | 2 +- .../scala/{rx/lang/scala => }/examples/RxScalaDemo.scala | 6 +++--- .../{rx/lang/scala => }/examples/TestSchedulerExample.scala | 5 ++--- src/main/scala/rx/lang/scala/schedulers/TestScheduler.scala | 3 ++- 8 files changed, 12 insertions(+), 14 deletions(-) rename examples/src/test/java/{rx/lang/scala => }/examples/MovieLibUsage.java (92%) rename examples/src/test/scala/{rx/lang/scala => }/examples/APICoverage.scala (99%) rename examples/src/test/scala/{rx/lang/scala => }/examples/ExperimentalAPIExamples.scala (99%) rename examples/src/test/scala/{rx/lang/scala => }/examples/MovieLib.scala (96%) rename examples/src/test/scala/{rx/lang/scala => }/examples/Olympics.scala (99%) rename examples/src/test/scala/{rx/lang/scala => }/examples/RxScalaDemo.scala (99%) rename examples/src/test/scala/{rx/lang/scala => }/examples/TestSchedulerExample.scala (94%) diff --git a/examples/src/test/java/rx/lang/scala/examples/MovieLibUsage.java b/examples/src/test/java/examples/MovieLibUsage.java similarity index 92% rename from examples/src/test/java/rx/lang/scala/examples/MovieLibUsage.java rename to examples/src/test/java/examples/MovieLibUsage.java index 8d3ceadb..2c115b95 100644 --- a/examples/src/test/java/rx/lang/scala/examples/MovieLibUsage.java +++ b/examples/src/test/java/examples/MovieLibUsage.java @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples; +package examples; import rx.Observable; import rx.functions.Action1; -import rx.lang.scala.examples.Movie; -import rx.lang.scala.examples.MovieLib; import static rx.lang.scala.JavaConversions.toScalaObservable; public class MovieLibUsage { diff --git a/examples/src/test/scala/rx/lang/scala/examples/APICoverage.scala b/examples/src/test/scala/examples/APICoverage.scala similarity index 99% rename from examples/src/test/scala/rx/lang/scala/examples/APICoverage.scala rename to examples/src/test/scala/examples/APICoverage.scala index fca9dcd6..707caead 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/APICoverage.scala +++ b/examples/src/test/scala/examples/APICoverage.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples +package examples import scala.collection.mutable diff --git a/examples/src/test/scala/rx/lang/scala/examples/ExperimentalAPIExamples.scala b/examples/src/test/scala/examples/ExperimentalAPIExamples.scala similarity index 99% rename from examples/src/test/scala/rx/lang/scala/examples/ExperimentalAPIExamples.scala rename to examples/src/test/scala/examples/ExperimentalAPIExamples.scala index 82d1fb87..e5b2d583 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/ExperimentalAPIExamples.scala +++ b/examples/src/test/scala/examples/ExperimentalAPIExamples.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples +package examples import scala.concurrent.duration._ import scala.language.postfixOps diff --git a/examples/src/test/scala/rx/lang/scala/examples/MovieLib.scala b/examples/src/test/scala/examples/MovieLib.scala similarity index 96% rename from examples/src/test/scala/rx/lang/scala/examples/MovieLib.scala rename to examples/src/test/scala/examples/MovieLib.scala index 8e2ce5b2..6790ff55 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/MovieLib.scala +++ b/examples/src/test/scala/examples/MovieLib.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples +package examples import rx.lang.scala.Observable diff --git a/examples/src/test/scala/rx/lang/scala/examples/Olympics.scala b/examples/src/test/scala/examples/Olympics.scala similarity index 99% rename from examples/src/test/scala/rx/lang/scala/examples/Olympics.scala rename to examples/src/test/scala/examples/Olympics.scala index 292fc041..08ef27f6 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/Olympics.scala +++ b/examples/src/test/scala/examples/Olympics.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples +package examples import rx.lang.scala.Observable import scala.concurrent.duration._ diff --git a/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala b/examples/src/test/scala/examples/RxScalaDemo.scala similarity index 99% rename from examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala rename to examples/src/test/scala/examples/RxScalaDemo.scala index 45564b1c..fb418dc2 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala +++ b/examples/src/test/scala/examples/RxScalaDemo.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples +package examples import java.io.IOException import java.util.concurrent.CountDownLatch @@ -708,8 +708,8 @@ class RxScalaDemo extends JUnitSuite { import Notification._ val oc1: Notification[Nothing] = OnCompleted val oc2: Notification[Int] = OnCompleted - val oc3: rx.Notification[_ <: Int] = oc2.asJavaNotification - val oc4: rx.Notification[_ <: Any] = oc2.asJavaNotification + val oc3: rx.Notification[_ <: Int] = JavaConversions.toJavaNotification(oc2) + val oc4: rx.Notification[_ <: Any] = JavaConversions.toJavaNotification(oc2) } @Test def takeWhileWithIndexAlternative { diff --git a/examples/src/test/scala/rx/lang/scala/examples/TestSchedulerExample.scala b/examples/src/test/scala/examples/TestSchedulerExample.scala similarity index 94% rename from examples/src/test/scala/rx/lang/scala/examples/TestSchedulerExample.scala rename to examples/src/test/scala/examples/TestSchedulerExample.scala index bf4afa9c..dff84be2 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/TestSchedulerExample.scala +++ b/examples/src/test/scala/examples/TestSchedulerExample.scala @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package rx.lang.scala.examples - import scala.concurrent.duration.DurationInt import scala.language.postfixOps import org.junit.Test @@ -24,6 +22,7 @@ import org.scalatest.junit.JUnitSuite import rx.lang.scala._ import rx.lang.scala.schedulers.TestScheduler import rx.observers.TestObserver +import rx.lang.scala.JavaConversions._ class TestSchedulerExample extends JUnitSuite { @@ -35,7 +34,7 @@ class TestSchedulerExample extends JUnitSuite { val o = Observable.interval(1 second, scheduler) // Wrap Java Observer in Scala Observer, then subscribe - val sub = o.subscribe(Observer(new TestObserver(observer))) + val sub = o.subscribe(toScalaObserver(new TestObserver(observer))) verify(observer, never).onNext(0L) verify(observer, never).onCompleted() diff --git a/src/main/scala/rx/lang/scala/schedulers/TestScheduler.scala b/src/main/scala/rx/lang/scala/schedulers/TestScheduler.scala index c8ddb766..b9433694 100644 --- a/src/main/scala/rx/lang/scala/schedulers/TestScheduler.scala +++ b/src/main/scala/rx/lang/scala/schedulers/TestScheduler.scala @@ -37,12 +37,13 @@ object TestScheduler { * @Test def testInterval() { * import org.mockito.Matchers._ * import org.mockito.Mockito._ + * import rx.lang.scala.JavaConversions._ * * val scheduler = TestScheduler() * val observer = mock(classOf[rx.Observer[Long]]) * * val o = Observable.interval(1 second, scheduler) - * val sub = o.subscribe(observer) + * val sub = o.subscribe(toScalaObserver(new TestObserver(observer))) * * verify(observer, never).onNext(0L) * verify(observer, never).onCompleted() From 28aa94bf6aa1498dbbf21fd5aeaab0686bbed9f2 Mon Sep 17 00:00:00 2001 From: Herman Banken Date: Sun, 31 May 2015 11:15:48 +0200 Subject: [PATCH 2/2] Add/fix references to RxScalaDemo's new location RxScalaDemo was moved to not longer be in rx.lang.scala, but references to this file may exist over the wiki and internet. Therefore this file is kept to guide users where to find it now. Fixes #167 --- CHANGES.md | 2 +- README.md | 2 +- .../src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala | 4 ++++ src/main/scala/rx/lang/scala/Observable.scala | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala diff --git a/CHANGES.md b/CHANGES.md index a4cbfce8..b12125f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,7 +31,7 @@ o1.switchIfEmpty(alternate).foreach(println) o2.switchIfEmpty(alternate).foreach(println) ``` -See more examples in [ExperimentalAPIExamples](/~https://github.com/ReactiveX/RxScala/blob/0.x/examples/src/test/scala/rx/lang/scala/examples/ExperimentalAPIExamples.scala) +See more examples in [ExperimentalAPIExamples](/~https://github.com/ReactiveX/RxScala/blob/0.x/examples/src/test/scala/examples/ExperimentalAPIExamples.scala) Because the APIs in ExperimentalAPIs depends on unstable APIs in RxJava, if you would like to use a custom RxJava version, it's better to check the compatibility in /~https://github.com/ReactiveX/RxScala#versioning diff --git a/README.md b/README.md index f82acaef..66bca55b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ def never: Observable[Nothing] 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). -For more examples, see [RxScalaDemo.scala](/~https://github.com/ReactiveX/RxScala/blob/0.x/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala). +For more examples, see [RxScalaDemo.scala](/~https://github.com/ReactiveX/RxScala/blob/0.x/examples/src/test/scala/examples/RxScalaDemo.scala). Scala code using Rx should only import members from `rx.lang.scala` and below. diff --git a/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala b/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala new file mode 100644 index 00000000..b34771ed --- /dev/null +++ b/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala @@ -0,0 +1,4 @@ +/** + * Moved to examples/src/test/scala/examples/RxScalaDemo.scala + * See /~https://github.com/ReactiveX/RxScala/blob/0.x/examples/src/test/scala/examples/RxScalaDemo.scala + */ diff --git a/src/main/scala/rx/lang/scala/Observable.scala b/src/main/scala/rx/lang/scala/Observable.scala index 4f6a8329..77909d40 100644 --- a/src/main/scala/rx/lang/scala/Observable.scala +++ b/src/main/scala/rx/lang/scala/Observable.scala @@ -4813,8 +4813,8 @@ object Observable { * See Rx Design Guidelines (PDF) for detailed * information. * - * See `RxScalaDemo.createExampleGood` - * and `RxScalaDemo.createExampleGood2`. + * See `RxScalaDemo.createExampleGood` + * and `RxScalaDemo.createExampleGood2`. * * @tparam T * the type of the items that this Observable emits