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

rename parameters in gui.js #42

Open
nikochiko opened this issue Oct 9, 2024 · 1 comment
Open

rename parameters in gui.js #42

nikochiko opened this issue Oct 9, 2024 · 1 comment

Comments

@nikochiko
Copy link
Member

The current signature is very misleading because its src=... argument does not take a javascript URL, but simply raw javascript code.

def js(src: str, **kwargs):
    ...

ExecJs only creates a Function out of it (using the raw body as the function's body, inside useEffect).

gooey-gui/app/renderer.tsx

Lines 456 to 471 in d6af022

function ExecJs({ src, args }: { args: any; src: any }) {
const submit = useSubmit();
args.gooeyRefresh = () => {
const elem = document.getElementById("gooey-form");
if (elem) submit(elem as HTMLFormElement, ...arguments);
};
useEffect(() => {
// eslint-disable-next-line no-new-func
const fn = new Function(...Object.keys(args), src);
fn(...Object.values(args));
}, [src, args]);
return null;
}

@nikochiko
Copy link
Member Author

let f = new Function("a", "b", "console.log(a);")

will be same as

let f = (a, b) => { console.log(a); }

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

1 participant