I think the big advantage of Promises/Futures is that you can pass a
Future/Promise around.  It also makes handling multiple asynchronous easier
than with callbacks (chaining vs nested callbacks).
Of course they have to be non-blocking.
Java8 and it's lambda constructs would make things much less verbose.
Dart has a really nice concept of Futures and internally uses it wherever
possible.

But you are also right. The solution you suggested (selecting the item in
the list in the onSuccess method is the way to go).


On Wed, Jul 10, 2013 at 6:28 PM, Jens <[email protected]> wrote:

>
> In general these kind of scenarios would be a good fit for
>> Futures/Promises especially if you depend on multiple asynchronous calls.
>> https://code.google.com/p/gwt-**async-future/<https://code.google.com/p/gwt-async-future/>
>
>
> IMHO Futures don't buy you anything in GWT. In Java Future.get() blocks
> until the result is available, in GWT you just can't do that. Thus you
> still need a callback so that you know when the Future has its result
> filled. Otherwise you would need a Timer and periodically check if the
> Future is ready to read. At the end you probably write more code than you
> should (in addition to the code you have introduced through the library
> itself).
>
>
>
>> https://code.google.com/p/**gwtquery/wiki/Promises<https://code.google.com/p/gwtquery/wiki/Promises>
>
>
> Looks a lot better but at the end its just a more declarative way of
> working with callbacks. I am not sure if this helps here.
> But because of the use of the Function interface it will probably read
> really well in IntelliJ and later helps a lot once GWT supports Java8
> lambdas. I do something similar, see
> https://groups.google.com/d/msg/google-web-toolkit-contributors/UzESJTd_JxU/p9UbnWxlWQQJ
>
>
>
> The key point is that Magnus wants to encapsulate asynchronous behavior
> but from the outside calls a synchronous method that depends on this
> encapsulated asynchronous behavior. IMHO the best way to solve this is to
> not be in that situation :-)
>
> -- J.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Web Toolkit" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-web-toolkit/VYazDZ2ys3U/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to