async function test() {
for (var i = 0; i < balance; i++) {
(async () => {
var a = await this.test1(i);
var b = await this.test2(a);
var c = await this.test3(b);
this.doThis(a,b,c);
})();
}
}
So I've concluded that (async () => {})();
is quite similar to a good old callbacks
function test() {
for (var i = 0; i < balance; i++) {
test1().call().then((a) => {
test2().call(a).then((b) => {
test3().call(b).then((c) => {
this.doThis(a,b,c);
});
});
});
}
}
Is this right? performance-wise I find they are about the same.
- Do they have any differences?
- What pattern should I follow?
I want to go with the first one async/await
, but if I take out (async () => {})();
I find it slower to render stuff in UI compare to the second one.