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

New bindJs template? #23

Open
neroist opened this issue Jun 23, 2023 · 4 comments
Open

New bindJs template? #23

neroist opened this issue Jun 23, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@neroist
Copy link
Member

neroist commented Jun 23, 2023

It would be cool to have some kind of "bindJS" template, where it takes the given Nim code and transpiles it to JS to then binds the generated JS code to the id.

@neroist
Copy link
Member Author

neroist commented Jun 23, 2023

Maybe a macro instead?

Proposed process:

  1. recieve code -> save to temp nim file -> transpile to JS function, output file to root folder
  2. transform original call to bind call, with the function body calling the generated JS function with run
  3. finally, link js file to html code

Should collect all JS code in the program then output all of it to the nim file.

@neroist
Copy link
Member Author

neroist commented Jun 23, 2023

Maybe also an additional defineJsFunction macro? Accepts function name and body and just simply transpiles code to JS and links to window

@neroist neroist added the enhancement New feature or request label Jun 23, 2023
@neroist
Copy link
Member Author

neroist commented Jun 23, 2023

Perhaps different names could be used aswell?

@neroist neroist added the help wanted Extra attention is needed label Jun 24, 2023
@hassandraga
Copy link
Member

I want to mention that webui_bind() works only before the window is shown. That's because we make webui.js listen only to the binded elements to avoid non-needed communication between UI and the backend.

But we can easily add new API to webui.js to add new elements in runtime. Please keep this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants