I am working on a karax app (built with nimib) that plots in canvas an object based on some inputs.
Right now I am calling the plot function (which ultimately is a script that updated the canvas element) after an input is changed, but I am sure there is a better way to do this. In particular I do not know how to have the plot function called at the beginning, when input is not changed.
app is here: https://pietroppeter.github.io/nblog/drafts/plant_app.html (plot function code is here: https://pietroppeter.github.io/nblog/drafts/plant_js.html)
In other SPA frameoworks what you are looking for would probably be named "lifecycle hooks", the closest I could find was postRenderCallback first implemented in this PR: https://github.com/karaxnim/karax/pull/16 It can be supplied using setRenderer: https://github.com/karaxnim/karax/blob/5498909fc565f6e32b26c3af7e3f5ad8f60b6e65/karax/karax.nim#L735
And because setRenderer is hidden in the convenient nbKarax template you will have to do it using the normal nbCodeToJs template instead.
indeed the postRender function works very well! updated app: https://pietroppeter.github.io/nblog/drafts/plant_app.html
in the code there I am now using a sketch implementation of karax widgets (and I added the equations in latex).