Skip to content

Commit 92f6bc1

Browse files
finish groupBy example
1 parent ff2b382 commit 92f6bc1

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/examples/Olympics.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ object Olympics {
4949
val neverUsedDummyMedal = Medal(3333, "?", "?", "?", "?", "?")
5050

5151
def fourYearsEmpty: Observable[Medal] = {
52-
Observable.interval(fourYears).take(1).map(i => neverUsedDummyMedal).filter(m => false)
52+
// TODO this should return an observable which emits nothing during fourYears and then completes
53+
// Because of https://github.com/Netflix/RxJava/issues/388, we get non-terminating tests
54+
// So we don't use this:
55+
// Observable.interval(fourYears).take(1).map(i => neverUsedDummyMedal).filter(m => false)
56+
// But we just return empty, which completes immediately
57+
Observable()
5358
}
5459

5560
}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ class RxScalaDemo extends JUnitSuite {
136136
}
137137

138138
@Test def testTwoSubscriptionsToOneInterval() {
139-
// TODO this does not yet work as expected!
140139
val o = Observable.interval(100 millis).take(8)
141140
o.subscribe(
142141
i => println(s"${i}a (on thread #${Thread.currentThread().getId()})")
@@ -178,22 +177,7 @@ class RxScalaDemo extends JUnitSuite {
178177
val t = for ((i, o) <- g; n <- o) yield n
179178
assertEquals(List(0, 1, 2, 3), t.toBlockingObservable.toList)
180179
}
181-
182-
@Test def groupByExampleTest() {
183-
val medalsByCountry = Olympics.mountainBikeMedals.groupBy(medal => medal.country)
184-
185-
val firstMedalOfEachCountry =
186-
medalsByCountry.flatMap((p: (String, Observable[Olympics.Medal])) => p._2.take(1))
187-
188-
firstMedalOfEachCountry.subscribe(medal => {
189-
println(s"${medal.country} wins its first medal in ${medal.year}")
190-
})
191-
192-
//waitFor(firstMedalOfEachCountry)
193-
Thread.sleep(20000)
194-
}
195-
196-
@Ignore // TODO this test one does not terminate!
180+
197181
@Test def groupByExample() {
198182
val medalsByCountry = Olympics.mountainBikeMedals.groupBy(medal => medal.country)
199183

0 commit comments

Comments
 (0)