3 ms·
I use Yue (libyue.com) with its Lua bindings. I compile Lua source files into a static binary, but I can flip a switch (in the environment) to load sources from
by wahern 4y ago
I use Yue (libyue.com) with its Lua bindings. I compile Lua source files into a static binary, but I can flip a switch (in the environment) to load sources from a specific directory. This isn't hot reload--currently I still need to restart the application--but it wouldn't be too difficult to hot reload the sources.
How and when views reflect the new code would be more complex, but AFAICT (from https://www.geeksforgeeks.org/hot-reload-in-electronjs/ https://www.geeksforgeeks.org/hot-reload-in-electronjs/) it's not exactly magic in Electron, either--browser views are reloaded in their entirety, and the main application is restarted entirely if its sources are changed, so you can lose state. You could probably do something more sophisticated in Lua, by dynamically updating the metatables of live objects (similar to prototypes in JS). That'd be a very leaky abstraction (presumably by Electron hot reload doesn't try it). You'd need to architect your code to be robust to missing or changed object state across versions of the code, or at least to annotate which objects are capable of being hot reloaded. But Smalltalk and, to a lesser extent, Objective-C developers have experience hot patching code this way, so it can be done.