3 ms·
Parallelizing is plain simple "await Promise.all([first, second])" Problem is doing some serious synchronization like n at a time or similar. Those things are b
by furstenheim 6y ago
Parallelizing is plain simple "await Promise.all([first, second])"
Problem is doing some serious synchronization like n at a time or similar. Those things are better of with callbacks
- _bxg1 6y agoThat's still clunkier than await first await second So lots of people might not ever think to do it the other way. If you don't have intimate knowledge of how promises work and what async/await really do, you might not even realize that this is wrong.
- furstenheim 6y agoYou can always move it to a variadic function and do await parallel(first, two) If your concern is clunkiness, I'm curious about callbacks, they're definitely more complex to use. I understand your point that not knowing how promises work can lead to not optimizing them, but going from one to the second can easily done on another iteration. On the other hand, not being capable with callbacks can easily lead to (callback) hell, then you need to first fix the mess, then optimize.