Thanks!

I ended up solving it a slightly different way by requiring another inner 
with the result type and doing a basic cast in an onComplete handler.

public Route askServiceAsync(ActorRef actorRef, Object message, Timeout 
timeout, Function<MyClass, Route> inner) {
    CompletionStage future = PatternsCS.ask(actorRef, message, timeout);
    return onComplete(future, (response) -> {
        return inner.apply((MyClass)response.get());
    });
}


On Tuesday, October 4, 2016 at 3:55:39 AM UTC-7, Josep Prat wrote:
>
> This is what I did in one of the projects:
>
> PatternsCS.ask(myActor, new MyActor.RetrieveFromUser(userId), 500)
>  .thenApply(OpenDuelActor.Answer.class::cast)
>  .thenApply(OpenDuelActor.Answer::getContent);
>
> Hope it's useful
>
> On Monday, October 3, 2016 at 10:56:00 PM UTC+2, [email protected] 
> wrote:
>>
>> I looked for that but CompletionStage doesn't have a map method. At least 
>> not in the Java8 version of java.util.concurrent.CompletionStage.
>>
>> On Monday, October 3, 2016 at 10:41:23 AM UTC-7, Josep Prat wrote:
>>>
>>> It's not very stylish, but you can call map on the CompletionStage doing 
>>> a cast to the desired class
>>
>>

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