I need to run multiple async operations, until one of them returns a certain result - in other words, the "Chain of Responsibility" pattern.
When I tried to implement it, some
was the first thing that came up. However I'm having troubles with the asynchronous calls, as the loop gets "stuck" after the first iteration:
asyncCalls.some(async (call) => {
const result = await call();
if (result === expectedResult) {
printResult(result);
}
return result === expectedResult;
});
Is there any way to iterate an array of async functions, with the possibility to break upon receiving a certain response?