Supposed I need to return a promise from my method, that depends on an external resource and some calculation. What I imagine is something like:
Promise<Integer> foo() {
return WS.url(url)
.getAsync()
.callWhenReady(new Function<HttpResponse>(){
Integer parse(HttpResponse response) {
// parsing business logic
// ...
int parsed = ...;
return parsed;
}
});
}
What can I use for callWhenReady? This is essentially just like jQuery.promise() behaves.
I think you want
F.Promise.map(Play 2.0.2):It seems from your code that you’re using an earlier version Play, but I think you should still just be able to replace
callWhenReadywithmap(and add anIntegertype parameter to your callback function).