Feature request: migration from callbacks towards asynchronous functions (await/async) in UI5-controllers
See original GitHub issueIssue:
Asynchronous functions (await
/async
) have been introduced to ECMAScript/JavaScript back in June 2016, since then await
/async
became a best practise for a writing an asynchronous code in JS, allowing to avoid a callback hell.
Unfortunately, UI5 stayed away from the trend and even in 2020 a typical UI5-controller from the very beginning contains at least two nested callback and looks likes:
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("ui5.tst.TST.controller.View1", {
onInit: function () {
/*…*/
}
});
});
Feature request:
To make a «facelifting» to all UI5-controllers and to refactor the codebase, moving from multiple nested callbacks towards asynchronous functions (await
/async
), making code less nested and therefore easier-to-read.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
From callbacks to async - await - A migration guide - LinkedIn
Therefore it made sense to take a function as an argument that would be called when the response is available, freeing the CPU...
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
To do this, you will first learn about the original way to ensure asynchronous code is handled correctly by the event loop: callback...
Read more >Asynchronous programming: futures, async, await | Dart
This codelab teaches you how to write asynchronous code using futures and the async and await keywords. Using embedded DartPad editors, you can...
Read more >Converting closure-based code into async/await in Swift
Swift provides a few methods we can use to convert callback-based ... If you wanted to start your async/await migration with this method, ......
Read more >Migrating from Promise chains to Async/Await - AfterAcademy
Several functions used in Javascript are asynchronous in nature and return Promises and you might need to implement those with traditional ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Totally agree with @pubmikeb . ES6/7 brings many conveniences to developers. If there is a plan to support it, I believe there will be many developers willing to participate, including me.
Yes, I realize the IE11-compatibility affects some modern standards adaptation. But what about providing two branches, let say, the modern and the legacy-one? For Chromium-based/Firefox browsers and for IE11 respectively. With an appropriate CI/CD infrastructure such task can be automated.
Anyway, the IE11 end-of-life is a matter of couple of next years, why not to let benefit from the modern standards out-of-box already today at least for those, who are not binded with the IE11 support?
P.S. Regardless the ES7 support, a TypeScript build of UI5 would be a prefect thing, especially due to its strong-typed nature.