I am currently trying to migrate a software and i encountered the following problems. In the current implementation, the graphical user interface makes use of a simple swing application.
Inside that class a special actor is created to listen to messages from other actors elsewhere.
Following is a small snippet of the codebase:
class App extends SimpleSwingApplication {
val actor = new Actor with Publisher {
override val scheduler = new SchedulerAdapter {
def execute(fun: => Unit) { Swing.onEDT(fun) }
}
def act() {
loop {
react {
case EXIT => exit
case msg: Event =>
println("Publishing This Msg: " + msg)
publish(msg)
case msg => println("Unknown Msg in GM: " + msg)
}
}
}
}
App.actor = actor
App.pub = actor
As you can see this actor extends the publisher trait which is used to capture reactions
from the user such as the selection of a menu item. The following snipet illustrates this:
listenTo(actor)
reactions += {
case st:State =>
playMenuItem.enabled = st match {case _:App.Playing => false; case _ => true}
stopMenuItem.enabled = st match {case App.Stopped => false; case _ => true}
}
Now the actual problem is how can i possibly migrate this to follow the akka-actor style. To my understanding the use of the publisher trait should be eliminated as it is a reactor itself (therefore deprecated to newer scala versions) and be replaced by messages.