Skip to content

Clean Context #104

Open
Open
@martinheidegger

Description

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
    });
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions