I\'m relatively new to the idea of actors, and was wondering if I could get some critique on what I am doing. For part of a project, I need to have an actor that tells a col
You can't remove state since TimeManager
should contain list of actors.
You could hide it:
class TimeManager extends Actor {
def receive = getBehavior(Nil)
def getBehavior(actors: List[ActorRef]): Receive = {
case AdvanceTime() => actors foreach (_ ! DateTime.now)
case AddListener(x) => context become getBehavior(x :: actors)
}
}
The strength of Scala is its hybrid of OO and Functional programming, scala developer don't need hate var
, if you do, you may need choose Haskell.
In your case, I think the only thing you need to change is to make actors
as private