Bug 566583 - [Databinding] Support for CompletableFuture
Summary: [Databinding] Support for CompletableFuture
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.16   Edit
Hardware: PC Windows 10
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-02 04:32 EDT by Lars Vogel CLA
Modified: 2021-12-29 16:57 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.