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

revamp(repl): Isolate each REPL instance #483

Merged
merged 7 commits into from
May 29, 2023
Merged

Conversation

PuruVJ
Copy link
Collaborator

@PuruVJ PuruVJ commented May 23, 2023

No description provided.

@vercel
Copy link

vercel bot commented May 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hn ❌ Failed (Inspect) May 29, 2023 10:00pm
svelte-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2023 10:00pm

@@ -84,6 +84,8 @@
ast = compiled.ast;
}

const { module_editor } = /** @type {import('../types').ReplContext}*/ (getContext('REPL'));
Copy link
Member

@dummdidumm dummdidumm May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid type casts, repetition of a string etc I suggest to move the set/getContext into a separate file like

// repl-context.js
const key = {}
/** @returns {..} */
export function getREPLContext() {
  return getContext(key);
}
/** @param {..} */
export function setREPLContext(value) {
  setContext(key, value);
}

Copy link
Collaborator Author

@PuruVJ PuruVJ May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's in its own file, I'm scared if it will undo the isolation. As in, if I have multiple <Repl>, won't they all have access to this same getContext in this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this works. I still don't understand how, but it works 😅

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

Successfully merging this pull request may close these issues.

2 participants