Skip to content

Instantly share code, notes, and snippets.

@concavelenz
Created July 30, 2021 18:18
Show Gist options
  • Save concavelenz/b17088c42cebf2367e7c5be3f618331e to your computer and use it in GitHub Desktop.
Save concavelenz/b17088c42cebf2367e7c5be3f618331e to your computer and use it in GitHub Desktop.
zone + async
async function myCode() {
const value = await doSomething();
const value2 = await somethingElse(value)
return value2 + 1;
}
async function myCode() {
const restoreZone = saveCurrentZone();
try {
const value = restoreZone(await doSomething());
const value2 = restoreZone(await somethingElse(value));
return value2 + 1;
} finally {
restoreZone(closeToken);
}
}
// global support
function saveCurrentZone() { ... }
const closeToken = {}; // globally unique object to use as a token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment