I'm newbie to reactivex, and try to use it with scala-swing.
My code is quite simple, but it doesn't work:
import rx.lang.scala.Observable
import scala.swing.{Frame, MainFrame, SimpleSwingApplication, TextField}
object HelloReactiveX extends SimpleSwingApplication {
val input = new TextField()
override def top: Frame = new MainFrame {
title = "Hello, reactivex"
contents = input
}
val stream = Observable[String] { subscriber =>
println("before input.subscribe")
input.subscribe {
case _ => {
println("input changed: " + input.text)
subscriber.onNext(input.text)
}
}
println("after input.subscribe")
}
stream.subscribe(t => println("###: " + t))
}
The dependency is:
"org.scala-lang.modules" %% "scala-swing" % "1.0.1",
"io.reactivex" %% "rxscala" % "0.25.0",
The strange thing is there is nothing printed to the console!
Is there anything wrong in my code?
PS: The live project is here https://github.com/freewind/scala-swing-demo/blob/fc79c5b65e6fecc21d3894888d336d8f5204f62e/src/main/scala/scalaswing/HelloReactiveX.scala