nim-webui
nim-webui copied to clipboard
New `bindJs` template?
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.
Maybe a macro instead?
Proposed process:
- recieve code -> save to temp nim file -> transpile to JS function, output file to root folder
- transform original call to
bind
call, with the function body calling the generated JS function withrun
- finally, link js file to html code
Should collect all JS code in the program then output all of it to the nim file.
Maybe also an additional defineJsFunction
macro? Accepts function name and body and just simply transpiles code to JS and links to window
Perhaps different names could be used aswell?
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.