Is there a way to invoke a method using a queue system? Imagine having a method that makes API calls and can only handle 3 calls at once. If more than 3 calls are made from a component, the remaining ones should wait until one call finishes before proceeding.
Just to clarify, this is not about looping API calls, but rather calling them based on user actions in a real project.
for (let i = 0; i < 9; i++) {
doSomething(i)
}
doSomething(param){
//call api
}
The goal is to execute doSomething for values 0 - 9, but ensuring that only the first 3 calls trigger API requests while the rest will be queued and wait for an available slot.