I have an array called "clickables" that I want to map over and do something with each element. However, I want to map over it in order, and asynchronously wait. That means for this code:
clickables = ['ele1', 'ele2', 'ele3']
clickables.map(async ele => {
await // action1
await // action2
});
I want ele1 to perform action 1 and then action 2. Ele2 will wait for ele1 to finish, and then perform action 1 and then action 2. Ele3 will wait for ele2 to finish, and so on.
Async await within the map obviously makes sure action 1 is performed before action 2 for each individual element, but it does not ensure that we wait for ele1 to finish before ele2 executes.
How can I do this?