-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add live-reload to new_example #19
base: main
Are you sure you want to change the base?
Conversation
The heavy lifting is done by exsync which supports both Mac and Linux https://github.com/falood/exsync Architecture When exsync detects a file system change it recompiles the changed filed into the BEAM. After this recompilation sequence finishes, it calls the configured callback function which is handled in the `Nav` component. The `Nav` component then restarts scenic by killing it's root process. If there was an easy/non-invasive way to get the current scene then we could restart just that instead of the entire process tree. Note: currently relies on an unreleased version of exsync.
Codecov Report
@@ Coverage Diff @@
## master #19 +/- ##
======================================
Coverage 96.5% 96.5%
======================================
Files 4 4
Lines 143 143
======================================
Hits 138 138
Misses 5 5 Continue to review full report at Codecov.
|
This is going to take me a while to think through. Not sure I want to take a dependency on exsync. There are Erlang apis to do similar tasks and may go that direction instead. No matter how it goes, love the research on this! |
Currently thinking Live Reload type functionality should exist in an optional package. Still thinking about the overall approach. |
Yeah, that's the direction I was leaning towards as well, although we may need some API changes in scenic itself to support it cleanly. I've been playing with a more general approach (although still dependent on exsync) that is suitable to an external library and I think that it would be helpful if Scenic supported a way to get the pids of the active top-level scenes. Here is a code snippet that has been working well for me so far (but obviously depends on Scenic internals):
|
I'm willing to expose/change the necessary api for this. Hope to get a large enough block of time to work on it - prob tomorrow. |
Sounds great! If you want to play with my scene reloading code above you can find it at axelson/scenic_asteroids@3481230 I'll clean it up before I merge it to master, but it has been working in the use-cases that I've tried so far. I investigated using |
@boydm I've cleaned up my generic scene reloader: axelson/scenic_asteroids#8 The main files of interest are:
Would be nice to have a public API to get the scene pids. |
@boydm I've further cleaned up my generic scene reloader into a re-usable library: https://github.com/axelson/scenic_live_reload/ Are you still willing to expose an api to get the pid of the root scene? Or provide a different way to reload the root scene? |
The heavy lifting is done by exsync which supports both Mac and Linux
https://github.com/falood/exsync
Architecture
When exsync detects a file system change it recompiles the changed filed into
the BEAM. After this recompilation sequence finishes, it calls the configured
callback function which is handled in the
Nav
component. TheNav
componentthen restarts scenic by killing it's root process.
If there was an easy/non-invasive way to get the current scene then we could
restart just that instead of the entire process tree.
Note: currently relies on an unreleased version of exsync.