Thursday, September 1, 2016

Re: synchronously waiting for a Promise

Jens, my suggestion was to propagate the asyncs up the call stack to all callers of the function, automatically changing each one to return a promise, and use await on the calls to the async functions, which would work fine except for losing the atomic synchonization of the functions effects in JS, relative to other events

On Thursday, 1 September 2016 15:10:12 UTC+1, Jens wrote:

var _symbol$bar = Symbol("Foo.bar");
class Foo {
  async getBar() { // Note: transformed to 'async', no 'synchronized'
    if (this[_symbol$bar] == null) {
      var realBar = …;
      this[_symbol$bar] = await realBar.get(); // transformed to await
    }
    return this[_symbol$bar];
  }
}

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?


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