Thursday, September 1, 2016

Re: synchronously waiting for a Promise


I think this isn't even correct, because "async getBar()" does return a promise simply because its marked async. Given that you can only call await inside async functions I think its nearly impossible to map that to a synchronous Java function while keeping the correct return type or am I missing something?

To be clear:

async getBar() {
  var str = await getSomeStringAsync();
  return str;
}

must map to Promise<String> / CompletableFuture<String> getBar() in Java just to get the return type correct. But that defeats the purpose of trying to make getBar() look synchronous in Java. And you can not internally unwrap that Promise (e.g. through getBar() implemented as getBarImpl().then(...)) synchronously.

So I think this can't really work.

-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment