-
-
Save getify/617c3fa3c835eac4c0f8adb739d62ab8 to your computer and use it in GitHub Desktop.
the "problem" with asynchronous closing of an async iterator
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 *getStuff(urls) { | |
showSpinner(); | |
try { | |
for (let url of urls) { | |
let resp = await fetch(url); | |
yield await resp.json(); | |
} | |
} | |
finally { | |
hideSpinner(); | |
} | |
} | |
var it = getStuff(contentURLs); | |
cancelBtn.addEventListener("click",() => it.return(),false); | |
for await (let stuff of it) { | |
render(stuff); | |
} | |
showSummary(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment