Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Context #104

Open
martinheidegger opened this issue Oct 7, 2024 · 1 comment
Open

Clean Context #104

martinheidegger opened this issue Oct 7, 2024 · 1 comment

Comments

@martinheidegger
Copy link

martinheidegger commented Oct 7, 2024

Having complex systems with various variables could result in leaking unintended values to subsystems. It might be reasonable to have something like AsyncContext.sandbox(() => {... }) which reset's all the state, preventing parents to interfere.

const asyncVar = new AsyncContext.Variable();

// Sets the current value to 'top', and executes the `main` function.
asyncVar.run("top", main);

function main() {
    AsyncContext.sandbox(() => {
      console.log(asyncVar.get()); // => undefined
    });
}
@Qard
Copy link

Qard commented Oct 10, 2024

Just for context, in Node.js this is store.exit(() => {}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants