To address the comments regarding the location of the API documentation for Actor.immutable:
As the Akka documentation clearly states, the Akka Typed API is still in flux:
This module is currently marked as may change in the sense of being the subject of active research. This means that API or semantics can change without warning or deprecation period and it is not recommended to use this module in production just yet—you have been warned.
Apparently you're using a pre-2.5.10 version of Akka: the Actor object was removed from the Akka Typed module in version 2.5.10.
- From Akka 2.5.2 to Akka 2.5.8, there was an
akka.typed.scaladsl.Actor.immutable method. - In Akka 2.5.9, the
Actor.immutable method moved to the akka.actor.typed package. - In Akka 2.5.10, the
akka.actor.typed.Actor object was removed. This object is still absent in 2.5.11 and 2.5.12 (the current version of Akka at the time of this writing).
Here is the Scaladoc for the last version of Actor.immutable from Akka 2.5.9:
def immutable[T](onMessage: (ActorContext[T], T) => Behavior[T]): Immutable[T]
Construct an actor behavior that can react to both incoming messages and lifecycle signals. After spawning this actor from another actor (or as the guardian of an akka.actor.typed.ActorSystem) it will be executed within an ActorContext that allows access to the system, spawning and watching other actors, etc.
This constructor is called immutable because the behavior instance does not need and in fact should not use (close over) mutable variables, but instead return a potentially different behavior encapsulating any state changes.
akka.typed.scaladsl.Actor-object. However: 1) I couldn't find any scaladocs online. 2) There isn't evenActor.scalain the packageakka-actor-typed/src/main/scala/akka/actor/typed/scaladslon github. I personally find the state of documentation (or rather, lack thereof), and the organization of the package a bit astonishing.