On Fri, Jul 7, 2017 at 3:10 PM, Jan-Terje Sørensen <[email protected]>
wrote:

> I have a API where I want to create a new user, and as a result of this
> API-call i would like to return the User-ID.
> How is it possible to receive a value from a tell? I have looked into
> Futures with no luck. I am trying to avoid Await.result, and solve it with
> a onSuccess. Anyone have a good code example?
>

Well, to begin with, this sort of problem is usually handled with ask(),
not tell() -- you should look into that.  (It's not strictly necessary, but
ask() is usually much less complex than trying to get results back from a
tell().)

And yes, ask() returns a Future, and yes, you should basically never use
Await in real code.  Instead, you need to get comfortable with
Future.map(), which is how you say "When this Future gets a value, do
something".  That and variations of it are the way you deal with messages
from Actors without messing up threading...

-- 
>>>>>>>>>>      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