Slide 34
Slide 34 text
Observable.toObservable("one",
"two",
"three")
.take(2)
.subscribe((arg)
-‐>
{
System.out.println(arg);
});
Java8
Observable.toObservable("one",
"two",
"three")
.take(2)
.subscribe((arg:
String)
=>
{
println(arg)
})
Scala
(-‐>
(Observable/toObservable
["one"
"two"
"three"])
(.take
2)
(.subscribe
(fn
[arg]
(println
arg))))
Clojure
Observable.toObservable("one",
"two",
"three")
.take(2)
.subscribe({arg
-‐>
println(arg)})
Groovy
Observable.toObservable("one",
"two",
"three")
.take(2)
.subscribe(lambda
{
|arg|
puts
arg
})
JRuby
34
Simple examples showing RxJava code in the 5 languages supported as of RxJava 0.5 (https://github.com/Netflix/RxJava/tree/master/language-adaptors). Java8 works with rxjava-core
and does not need a language-adaptor. It also works with Java 6/7 but without lambdas/closures the code is more verbose.