ReactiveX / RxScala

RxScala – Reactive Extensions for Scala – a library for composing asynchronous and event-based programs using observable sequences
Apache License 2.0
888 stars 110 forks source link

Doesn't work well with scala-swing? #179

Closed freewind closed 9 years ago

freewind commented 9 years ago

Described here, thanks: http://stackoverflow.com/questions/33627505/reactivex-in-scala-swing-doesnt-work

zsxwing commented 9 years ago

Looks this is not an RxScala issue.

freewind commented 9 years ago

Just found it works well with jdk1.7 & 1.8, but failed with jdk 1.6

freewind commented 9 years ago

Seems like I have to add the lib "io.reactivex" % "rxswing" % "0.21.0", and

  val eventScheduler = rx.lang.scala.JavaConversions.javaSchedulerToScalaScheduler(SwingScheduler.getInstance)
stream.observeOn(eventScheduler).subscribe(t => println("###: " + t))

to make it work with jdk 1.6

zsxwing commented 9 years ago

I know nothing about Scala Swing. But for Java Swing, you should touch the UI stuff only in the UI event queue because most of UI components are not thread safe. See https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

freewind commented 9 years ago

OK, and thanks, this can be a reminder for other guys who wants to use rxscala with scala-swing