It's easy to do that by mistake, for example:

  class ActorA extends Actor {
    def receive = {
      case "hi" =>
        // THIS IS A BUG
        context.actorOf(Props(new ActorB(sender())))
    }
  }

The safe convention:

  class ActorA extends Actor {
    def receive = {
      case "hi" =>
        context.actorOf(ActorB.props(sender()))
    }
  }

  object ActorB {
    def props(replyTo: ActorRef): Props =
      new Props(new ActorB(replyTo))
  }

/Patrik


On Thu, Dec 15, 2016 at 1:14 PM, Rafał Krzewski <[email protected]>
wrote:

> W dniu czwartek, 15 grudnia 2016 08:02:29 UTC+1 użytkownik Dmb napisał:
>>
>>
>> Do you mean that the state of the outer actor can be used from the inner
>> actor by mistake? It sounds a little nonsensical to me to use one actor
>> from another directly (not by sending a message).
>>
>
> You are right, but since Scala happily captures vars or val references to
> mutable objects when creating closures its' rather easy to do this by
> mistake.
>
> Cheers,
> Rafa
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Akka Tech Lead
Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to