Let typed Stateful optionally handle signals also, #22293

* and thereby no need for MessageOrSignal
This commit is contained in:
Patrik Nordwall 2017-03-16 14:44:03 +01:00
parent b2b4f64d97
commit f485be2bf5
8 changed files with 122 additions and 128 deletions

View file

@ -114,7 +114,8 @@ class IntroSpec extends TypedSpec {
//#chatroom-main
val main: Behavior[akka.NotUsed] =
SignalOrMessage(
Stateful(
behavior = (_, _) Unhandled,
signal = { (ctx, sig)
sig match {
case PreStart
@ -128,8 +129,7 @@ class IntroSpec extends TypedSpec {
case _
Unhandled
}
},
mesg = (_, _) Unhandled)
})
val system = ActorSystem("ChatRoomDemo", main)
Await.result(system.whenTerminated, 1.second)

View file

@ -248,7 +248,7 @@ Actor will perform its job on its own accord, we do not need to send messages
from the outside, so we declare it to be of type ``NotUsed``. Actors receive not
only external messages, they also are notified of certain system events,
so-called Signals. In order to get access to those we choose to implement this
particular one using the :class:`SignalOrMessage` behavior decorator. The
particular one using the :class:`Stateful` behavior decorator. The
provided ``signal`` function will be invoked for signals (subclasses of :class:`Signal`)
or the ``mesg`` function for user messages.