Skip to content

Commit 6e7772d

Browse files
make Olympics example data timed
1 parent ed030db commit 6e7772d

File tree

1 file changed

+43
-27
lines changed
  • language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/examples

1 file changed

+43
-27
lines changed
Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,55 @@
11
package rx.lang.scala.examples
22

3+
import rx.lang.scala.Observable
4+
import scala.concurrent.duration._
5+
36
object Olympics {
47
case class Medal(val year: Int, val games: String, val discipline: String, val medal: String, val athlete: String, val country: String)
58

6-
val mountainBikeMedals = List(
7-
Medal(2012, "London 2012", "cross-country men", "Gold", "Jaroslav KULHAVY", "Czech Republic"),
8-
Medal(2012, "London 2012", "cross-country men", "Silver", "Nino SCHURTER", "Switzerland"),
9-
Medal(2012, "London 2012", "cross-country men", "Bronze", "Marco Aurelio FONTANA", "Italy"),
10-
Medal(2012, "London 2012", "cross-country women", "Gold", "Julie BRESSET", "France"),
11-
Medal(2012, "London 2012", "cross-country women", "Silver", "Sabine SPITZ", "Germany"),
12-
Medal(2012, "London 2012", "cross-country women", "Bronze", "Georgia GOULD", "United States of America"),
13-
Medal(2008, "Beijing 2008", "cross-country women", "Gold", "Sabine SPITZ", "Germany"),
14-
Medal(2008, "Beijing 2008", "cross-country women", "Silver", "Maja WLOSZCZOWSKA", "Poland"),
15-
Medal(2008, "Beijing 2008", "cross-country women", "Bronze", "Irina KALENTYEVA", "Russian Federation"),
16-
Medal(2008, "Beijing 2008", "cross-country men", "Gold", "Julien ABSALON", "France"),
17-
Medal(2008, "Beijing 2008", "cross-country men", "Silver", "Jean-Christophe PERAUD", "France"),
18-
Medal(2008, "Beijing 2008", "cross-country men", "Bronze", "Nino SCHURTER", "Switzerland"),
19-
Medal(2004, "Athens 2004", "cross-country men", "Gold", "Julien ABSALON", "France"),
20-
Medal(2004, "Athens 2004", "cross-country men", "Silver", "Jose Antonio HERMIDA RAMOS", "Spain"),
21-
Medal(2004, "Athens 2004", "cross-country men", "Bronze", "Bart BRENTJENS", "Netherlands"),
22-
Medal(2004, "Athens 2004", "cross-country women", "Gold", "Gunn-Rita DAHLE", "Norway"),
23-
Medal(2004, "Athens 2004", "cross-country women", "Silver", "Marie-Helene PREMONT", "Canada"),
24-
Medal(2004, "Athens 2004", "cross-country women", "Bronze", "Sabine SPITZ", "Germany"),
9+
def mountainBikeMedals: Observable[Medal] = Observable(
10+
Medal(1996, "Atlanta 1996", "cross-country men", "Gold", "Bart BRENTJENS", "Netherlands"),
11+
Medal(1996, "Atlanta 1996", "cross-country women", "Gold", "Paola PEZZO", "Italy"),
12+
Medal(1996, "Atlanta 1996", "cross-country men", "Silver", "Thomas FRISCHKNECHT", "Switzerland"),
13+
Medal(1996, "Atlanta 1996", "cross-country women", "Silver", "Alison SYDOR", "Canada"),
14+
Medal(1996, "Atlanta 1996", "cross-country men", "Bronze", "Miguel MARTINEZ", "France"),
15+
Medal(1996, "Atlanta 1996", "cross-country women", "Bronze", "Susan DEMATTEI", "United States of America")
16+
) ++ fourYearsEmpty ++ Observable(
2517
Medal(2000, "Sydney 2000", "cross-country women", "Gold", "Paola PEZZO", "Italy"),
2618
Medal(2000, "Sydney 2000", "cross-country women", "Silver", "Barbara BLATTER", "Switzerland"),
2719
Medal(2000, "Sydney 2000", "cross-country women", "Bronze", "Marga FULLANA", "Spain"),
2820
Medal(2000, "Sydney 2000", "cross-country men", "Gold", "Miguel MARTINEZ", "France"),
2921
Medal(2000, "Sydney 2000", "cross-country men", "Silver", "Filip MEIRHAEGHE", "Belgium"),
30-
Medal(2000, "Sydney 2000", "cross-country men", "Bronze", "Christoph SAUSER", "Switzerland"),
31-
Medal(1996, "Atlanta 1996", "cross-country men", "Silver", "Thomas FRISCHKNECHT", "Switzerland"),
32-
Medal(1996, "Atlanta 1996", "cross-country men", "Bronze", "Miguel MARTINEZ", "France"),
33-
Medal(1996, "Atlanta 1996", "cross-country men", "Gold", "Bart BRENTJENS", "Netherlands"),
34-
Medal(1996, "Atlanta 1996", "cross-country women", "Gold", "Paola PEZZO", "Italy"),
35-
Medal(1996, "Atlanta 1996", "cross-country women", "Silver", "Alison SYDOR", "Canada"),
36-
Medal(1996, "Atlanta 1996", "cross-country women", "Bronze", "Susan DEMATTEI", "United States of America")
37-
).reverse
22+
Medal(2000, "Sydney 2000", "cross-country men", "Bronze", "Christoph SAUSER", "Switzerland")
23+
) ++ fourYearsEmpty ++ Observable(
24+
Medal(2004, "Athens 2004", "cross-country men", "Gold", "Julien ABSALON", "France"),
25+
Medal(2004, "Athens 2004", "cross-country men", "Silver", "Jose Antonio HERMIDA RAMOS", "Spain"),
26+
Medal(2004, "Athens 2004", "cross-country men", "Bronze", "Bart BRENTJENS", "Netherlands"),
27+
Medal(2004, "Athens 2004", "cross-country women", "Gold", "Gunn-Rita DAHLE", "Norway"),
28+
Medal(2004, "Athens 2004", "cross-country women", "Silver", "Marie-Helene PREMONT", "Canada"),
29+
Medal(2004, "Athens 2004", "cross-country women", "Bronze", "Sabine SPITZ", "Germany")
30+
) ++ fourYearsEmpty ++ Observable(
31+
Medal(2008, "Beijing 2008", "cross-country women", "Gold", "Sabine SPITZ", "Germany"),
32+
Medal(2008, "Beijing 2008", "cross-country women", "Silver", "Maja WLOSZCZOWSKA", "Poland"),
33+
Medal(2008, "Beijing 2008", "cross-country women", "Bronze", "Irina KALENTYEVA", "Russian Federation"),
34+
Medal(2008, "Beijing 2008", "cross-country men", "Gold", "Julien ABSALON", "France"),
35+
Medal(2008, "Beijing 2008", "cross-country men", "Silver", "Jean-Christophe PERAUD", "France"),
36+
Medal(2008, "Beijing 2008", "cross-country men", "Bronze", "Nino SCHURTER", "Switzerland")
37+
) ++ fourYearsEmpty ++ Observable(
38+
Medal(2012, "London 2012", "cross-country men", "Gold", "Jaroslav KULHAVY", "Czech Republic"),
39+
Medal(2012, "London 2012", "cross-country men", "Silver", "Nino SCHURTER", "Switzerland"),
40+
Medal(2012, "London 2012", "cross-country men", "Bronze", "Marco Aurelio FONTANA", "Italy"),
41+
Medal(2012, "London 2012", "cross-country women", "Gold", "Julie BRESSET", "France"),
42+
Medal(2012, "London 2012", "cross-country women", "Silver", "Sabine SPITZ", "Germany"),
43+
Medal(2012, "London 2012", "cross-country women", "Bronze", "Georgia GOULD", "United States of America")
44+
)
45+
46+
// speed it up :D
47+
val fourYears = 4000.millis
48+
49+
val neverUsedDummyMedal = Medal(3333, "?", "?", "?", "?", "?")
50+
51+
def fourYearsEmpty: Observable[Medal] = {
52+
Observable.interval(fourYears).take(1).map(i => neverUsedDummyMedal).filter(m => false)
53+
}
3854

3955
}

0 commit comments

Comments
 (0)