Bug 566583

Summary: [Databinding] Support for CompletableFuture
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: jens, Lars.Vogel
Version: 4.16   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Lars Vogel CLA 2020-09-02 04:32:02 EDT
I have multiple customers using asynchronous reading of data via CompletableFuture. AFAIK we do not have yet support in Databinding for this constructed, e.g.:

CompletableFuture<Person> p = serverCall();

Would be useful IMHO to allow to find this via databinding so that once the future finishes the databinding is updating the bound properties.
Comment 1 Lars Vogel CLA 2020-09-02 04:32:46 EDT
Jens, WDYT?
Comment 2 Jens Lideström CLA 2020-09-02 09:41:18 EDT
(In reply to Lars Vogel from comment #1)
> Jens, WDYT?

It sound like an interesting idea!

I don't understand exactly what you're thinking.

To have a CompletableFuture value propagated to the databinding framework I guess you have to do something like this today:

    IObservableValue<String> o = new WritableValue<>();

    CompletableFuture<String> f = new CompletableFuture<>();

    f.whenComplete((s, exc) -> {
        o.getRealm().asyncExec(() -> o.setValue(s)));

Is the new functionality that you're suggesting a way to make this easier and more natural?
Comment 3 Lars Vogel CLA 2020-09-07 08:44:06 EDT
(In reply to Jens Lideström from comment #2)
> (In reply to Lars Vogel from comment #1)
> > Jens, WDYT?
> 
> It sound like an interesting idea!
> 
> I don't understand exactly what you're thinking.
> 
> To have a CompletableFuture value propagated to the databinding framework I
> guess you have to do something like this today:
> 
>     IObservableValue<String> o = new WritableValue<>();
> 
>     CompletableFuture<String> f = new CompletableFuture<>();
> 
>     f.whenComplete((s, exc) -> {
>         o.getRealm().asyncExec(() -> o.setValue(s)));
> 
> Is the new functionality that you're suggesting a way to make this easier
> and more natural?

Thanks for the reply. Yes, I think the above coding could be easier. Maybe something like a WritableValueCompletableFuture which does the above automatically.