I am relatively new to the idea of actors, and I was interested to know if I can criticize what I do. For part of the project I need an actor who will tell the collective of listening actors time. Performing actors must be added to this actor.
I currently have this:
import akka.actor.Actor;
import akka.actor.ActorRef;
import com.github.nscala_time.time.Imports._;
class TimeManager extends Actor {
var actors:List[ActorRef] = List();
def receive = {
case AdvanceTime() => actors foreach (_ ! DateTime.now)
case AddListener(x) => actors = x :: actors
}
}
Is there any way to remove the state (var actors) from this code to make it more functional?
source
share