Skip to content

Commit 7273063

Browse files
committed
Merge pull request ReactiveX#1 from samuelgruetter/RxJavaBugFixesSam
A few trivial Scala adaptor details
2 parents 8ae65eb + 9ecbd5c commit 7273063

File tree

9 files changed

+39
-47
lines changed

9 files changed

+39
-47
lines changed

gradlew

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ DEFAULT_JVM_OPTS=""
1212
APP_NAME="Gradle"
1313
APP_BASE_NAME=`basename "$0"`
1414

15-
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home"
16-
1715
# Use the maximum available, or set MAX_FD != -1 to use that value.
1816
MAX_FD="maximum"
1917

language-adaptors/rxjava-scala/src/examples/scala/rx/lang/scala/examples/RxScalaDemo.scala

-34
Original file line numberDiff line numberDiff line change
@@ -427,40 +427,6 @@ class RxScalaDemo extends JUnitSuite {
427427
assertEquals("!!", Observable("a", "b", "c").drop(10).firstOrElse("!!").toBlockingObservable.single)
428428
}
429429

430-
@Test def observableLikeFuture1() {
431-
implicit val scheduler = ThreadPoolForIOScheduler()
432-
val o1 = Observable {
433-
Thread.sleep(1000)
434-
5
435-
}
436-
val o2 = Observable {
437-
Thread.sleep(500)
438-
4
439-
}
440-
Thread.sleep(500)
441-
val t1 = System.currentTimeMillis
442-
println((o1 merge o2).first.toBlockingObservable.single)
443-
println(System.currentTimeMillis - t1)
444-
}
445-
446-
@Test def ObservableLikeFuture2() {
447-
class Friend {}
448-
val session = new Object {
449-
def getFriends: List[Friend] = List(new Friend, new Friend)
450-
}
451-
452-
implicit val scheduler = ThreadPoolForIOScheduler()
453-
val o: Observable[List[Friend]] = Observable {
454-
session.getFriends
455-
}
456-
o.subscribe(
457-
friendList => println(friendList),
458-
err => println(err.getMessage)
459-
)
460-
461-
Thread.sleep(1500) // or convert to BlockingObservable
462-
}
463-
464430
@Test def takeWhileWithIndexAlternative {
465431
val condition = true
466432
Observable("a", "b").zipWithIndex.takeWhile{case (elem, index) => condition}.map(_._1)

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/ImplicitFunctionConversions.scala

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ package rx.lang.scala
1717

1818
import java.lang.Exception
1919
import java.{ lang => jlang }
20-
//import rx.lang.scala._
21-
import rx.util.functions._
20+
2221
import scala.collection.Seq
23-
import java.{lang => jlang}
2422
import scala.language.implicitConversions
25-
//import rx.lang.scala.Scheduler
23+
24+
import rx.util.functions._
2625

2726
/**
2827
* These function conversions convert between Scala functions and Rx `Func`s and `Action`s.

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@ trait Observable[+T]
280280
* corresponding elements using the selector function.
281281
* The number of `onNext` invocations of the resulting `Observable[(T, U)]`
282282
* is the minumum of the number of `onNext` invocations of `this` and `that`.
283+
*
284+
* Note that this function is private because Scala collections don't have such a function.
283285
*/
284-
def zip[U, R](that: Observable[U], selector: (T,U) => R): Observable[R] = {
286+
private def zip[U, R](that: Observable[U], selector: (T,U) => R): Observable[R] = {
285287
Observable[R](rx.Observable.zip[T, U, R](this.asJavaObservable, that.asJavaObservable, selector))
286288
}
287289

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/concurrency/ThreadPoolForComputationScheduler.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ object ThreadPoolForComputationScheduler {
2626
*
2727
* This can be used for event-loops, processing callbacks and other computational work.
2828
*
29-
* Do not perform IO-bound work on this scheduler. Use [[rx.lang.scala.concurrency.Schedulers.threadPoolForIO]] instead.
29+
* Do not perform IO-bound work on this scheduler. Use [[rx.lang.scala.concurrency.ThreadPoolForIOScheduler]] instead.
3030
*/
31-
def apply(): ThreadPoolForComputationScheduler = {
31+
def apply(): ThreadPoolForComputationScheduler = {
3232
new ThreadPoolForComputationScheduler(rx.concurrency.Schedulers.threadPoolForComputation())
3333
}
3434
}

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/concurrency/ThreadPoolForIOScheduler.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ object ThreadPoolForIOScheduler {
2626
*
2727
* This can be used for asynchronously performing blocking IO.
2828
*
29-
* Do not perform computational work on this scheduler. Use [[rx.lang.scala.concurrency.Schedulers.threadPoolForComputation]] instead.
29+
* Do not perform computational work on this scheduler. Use [[rx.lang.scala.concurrency.ThreadPoolForComputationScheduler]] instead.
3030
*/
31-
def apply(): ThreadPoolForIOScheduler = {
31+
def apply(): ThreadPoolForIOScheduler = {
3232
new ThreadPoolForIOScheduler(rx.concurrency.Schedulers.threadPoolForIO())
3333
}
3434
}

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/package.scala

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
*/
1616
package rx.lang
1717

18-
package object scala {
19-
}
18+
/**
19+
* This package contains all classes that RxScala users need.
20+
*
21+
* It basically mirrors the structure of package `rx`, but some changes were made to make it more Scala-idiomatic.
22+
*/
23+
package object scala {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2013 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package rx.lang.scala
17+
18+
/**
19+
* Subjects are Observers and Observables at the same time.
20+
*/
21+
package object subjects {}

language-adaptors/rxjava-scala/src/test/scala/rx/lang/scala/subscriptions/SubscriptionTests.scala

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import org.junit.Assert._
44
import org.junit.Test
55
import org.scalatest.junit.JUnitSuite
66

7+
import rx.lang.scala.Subscription
8+
79
class SubscriptionTests extends JUnitSuite {
810

911
@Test

0 commit comments

Comments
 (0)