Hi 

Yes i do really need to have  2 receive functions . The reason is that when 
i override my receive function from another class, i lose all the cases 
defined in it, just to override one of the cases.

for example: 

def receive = {

case one =>//some logic

case two => //some logic

}



when i am doing this:

override receive = {

case one => //some overridden logic


}



here , i lose the case two defined in my previous receive , which i don't 
want to define again.

Is there any other way to achieve that? or can we dynamically add a case to 
receive function ?

Thanks in Advance.



On Tuesday, July 12, 2016 at 2:38:05 AM UTC+5:30, Justin du coeur wrote:
>
> An Actor can only have one Receive method active at any given time; by 
> default, it's the value of receive.  You can't just add another method and 
> have it work -- it'll never be used unless you become(handler).  (Or 
> compose the two PartialFunctions together and set receive to that.)
>
> Is there a reason for wanting two separate Receive functions?
>
> On Mon, Jul 11, 2016 at 4:24 PM, <ani...@egnaroinc.com <javascript:>> 
> wrote:
>
>> Hi
>>
>> I have a class 
>>  MyActorClass(out,post)
>>
>> where out and post are 2 actors passed as an argument to it. It has a 
>> receive function like this:
>> def receive = {
>>
>> case msg:String =>  myfunction
>>
>> }
>>
>>
>>
>> and another receive function as:
>>
>> def handler:Receive = {
>>
>> case handlingMsg =>  //some logic
>>
>> case handlingMsgAgain => //some logic
>>
>> }
>>
>>
>>
>> Now in 
>> myfunction 
>>
>> body , am calling the 
>> post ! handlingMsg
>>
>> . But somehow it is not working and also not showing any error. It works 
>> if i shift my 
>> handlingMsg
>>
>> case in receive method.What am i doing wrong here?
>>
>> -- 
>> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> 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