Don't do static global state, it's a bad code smell in general.

-- 
Konrad `ktoso` Malawski
Akka <http://akka.io> @ Lightbend <http://lightbend.com>

On 19 July 2016 at 10:05:11, James (breath...@gmail.com) wrote:

Thank you Rob,

Another way is to pass the actorRef  to a static object, which can be
referenced by other instances later. I am wondering which way is better:
pass the actoreRef to a class instance or assign the actoreRef to a static
attribute in an object.

Best,

James



On Tuesday, July 19, 2016 at 4:29:28 AM UTC+8, Rob Crawford wrote:
>
> If the Actor gets restarted, the ActorRef will still be valid. That's one
> of the reasons for ActorRef.
>
> On Monday, July 18, 2016 at 3:16:13 PM UTC-4, James wrote:
>>
>> Hi,
>>
>> The document saying
>>
>> "It is always preferable to communicate with other Actors using their
>> ActorRef instead of relying upon ActorSelection.
>> In all other cases ActorRefs can be provided during Actor creation or
>> initialization, passing them from parent to child or introducing Actors by
>> sending their ActorRefs to other Actors within messages"
>>
>>
>> I am trying to follow this design pattern to pass an actorRef to another
>> class instance. But my question is what happens if this actor gets
>> restarted? Can the class instance get the new actoreRef automatically?
>> What would be the best approach  to handle this issue to have the class
>> instance got the new restarted actorRef automatically?
>>
>> Thank you very much!
>>
>> James
>>
> --
>>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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