Open neroist opened 1 year ago
Maybe a macro instead?
Proposed process:
bind
call, with the function body calling the generated JS function with run
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.
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.