Basilevs Basilevs - 4 months ago 44
Scala Question

Event handling in Scala

What should I use to implement simple event handling in Scala?

I don't want to rely on Scala.Swing APIs and I'm not sure if I should use Actors.

What I need is simple generic over event type handlers and event sources. Concurrency is not a requirement. Aren't Actors too heavy for simple tasks requiring no concurrency?


If you don't want to rely on Scala Swing and you only require publishers and observers, why not roll up your own implementation? This would amount to 2-3, below-10-line Scala traits (depending on whether you also want event buses or not).

If you don't mind a more complex API (especially since you're getting concurrency handling for free), you could try out the Observables out of RxScala. Take a look at the aforementioned Observable, Observer and Subject APIs.