Created
March 27, 2020 00:17
-
-
Save fabiosantoscode/bea0bd4b9ac6b976556044f350ef3f97 to your computer and use it in GitHub Desktop.
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
// async function fetchRefs(obj) | |
const allPromises = [] | |
;(function fetchRefs(obj) { | |
for (let key in obj) { | |
if (isRef(obj[key]) { | |
const promise = fetchRef(obj[key]) | |
allPromises.push(promise) | |
promise.then(value => { obj[key] = value }) | |
} else if (isObject(obj[key]) { | |
fetchRefs(obj[key]) | |
} | |
} | |
}(obj)) | |
await Promise.all(allPromises) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment