nbb

Vladimir Pouzanov 2024-03-23T15:24:32.827369Z

is there any way to run a function when I send a form from my editor (VSCode/calva) to nbb? I’m basically looking for some quick server side react-based rendering and I want to refresh on eval

borkdude 2024-03-23T16:37:52.989169Z

I'm not sure if this is a Calva or nbb question

Vladimir Pouzanov 2024-03-23T16:51:47.459859Z

I thought there might be some generic nbb mechanism to do that

borkdude 2024-03-23T16:56:35.134279Z

I'm not sure what or how that would work, perhaps you can chop up the question into sub-problems

borkdude 2024-03-23T16:57:04.352049Z

or perhaps @pez has an idea from the calva side

Vladimir Pouzanov 2024-03-23T16:59:55.938509Z

right. So, ultimately I want a cljs script that runs with nbb and spits out some html into a file. I'd like that script to also run a http server to serve the said file and reload the browser when that file changes. The latter is reasonably doable with some npm (e.g. refresh). But I'd have to call into refresh from the repl to actually tell it to refresh, and I'd like for it to refresh on every form change, e.g. if I build that html with nbb's Reagent, I want it to refresh when I send new subelements from the editor to the REPL.

Vladimir Pouzanov 2024-03-23T17:02:03.687709Z

I think I could use joyride to make a new vscode hotkey that uses the calva API to evaluate the top-level form and then the command to refresh the page... actually I might try just that.

Vladimir Pouzanov 2024-03-23T17:07:11.039069Z

I think sitefox mostly satisfies my case. It reloads when cljs is saved. That's good enough https://github.com/chr15m/sitefox/blob/main/create/sitefox-nbb/template/server.cljs#L41

Chris McCormick 2024-04-08T20:32:54.245799Z

I found the watch-files reloading a bit buggy (it would occasionally just stop reloading after a while) but I could never figure out why. Hopefully it works better for you. If you run into any problems please feel free to file an issue against Sitefox.