This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The function | |
function subscribe(promises, cb) { | |
let result = Array.from({ length: promises.length }).fill(null); | |
promises.forEach((promise, index) => { | |
promise.then(val => { | |
const clonedResult = [...result]; | |
clonedResult[index] = val; | |
cb(clonedResult); | |
result = clonedResult; |
OlderNewer