Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified API for background/asynchronous code #2174

Closed
Fedoseew opened this issue Aug 28, 2023 · 1 comment · Fixed by #3425
Closed

Simplified API for background/asynchronous code #2174

Fedoseew opened this issue Aug 28, 2023 · 1 comment · Fixed by #3425

Comments

@Fedoseew
Copy link

Fedoseew commented Aug 28, 2023

Main goal

To simplify the work with asynchronous/background calls.

Description

At the moment we have a BackgroundTask mechanism. This mechanism is in some cases too redundant and looks too complicated.
For example, if we need to load some data and then process the result (on UI thread), then we will have to write a lot of code to achieve the desired result and so on every time, for every such call. This may scare off novice developers a little and annoy others.

Suggestion

It would be convenient to use something like AsyncUtil.executeInBackground(currentView, dataFetchingSupplier, resultHandlerConsumer).
You can also see an example of this approach in the Async Manager addon .

I attach an approximate implementation (UiUtils.txt) that was used on one of the projects, together with the above addon (may be it will be useful).

@Fedoseew Fedoseew changed the title Simplified api for background/asynchronous code Simplified API for background/asynchronous code Aug 28, 2023
@gorbunkov gorbunkov added candidate Possible candidate for future releases size: M labels Dec 15, 2023
@knstvk knstvk added this to October 2024 release in Jmix Roadmap Feb 21, 2024
@glebfox
Copy link
Contributor

glebfox commented Feb 26, 2024

Vaadin has a Debouncer for JS code that is used to collapse multiple callbacks into one invocation after a timer. For example:

this.__debounceSetValue = Debouncer.debounce(this.__debounceSetValue, timeOut.after(timeout), () => {
    this.value = JSON.stringify(this._editor.getContents().ops);
});

...

if (this.__debounceSetValue && this.__debounceSetValue.isActive()) {
    lastCommittedChange = this.value;
    this.__debounceSetValue.flush();
}

@gorbunkov gorbunkov linked a pull request Jun 27, 2024 that will close this issue
@knstvk knstvk removed the candidate Possible candidate for future releases label Jun 28, 2024
@gorbunkov gorbunkov self-assigned this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: October 2024 release
Status: Done
Jmix Roadmap
October 2024 release
Development

Successfully merging a pull request may close this issue.

4 participants