ScenicLiveReload
A live reloader for Scenic. Once configured, when you edit a file the current root scene will be killed, when it is restarted it will use any new code currently in the running beam instance.
How it works:
- Uses exsync to watch the file system
- When you edit a file with your editor, exsync recompiles and reloads that beam file
exsyncnotifiesscenic_live_reloadthat files were reloadedscenic_live_reloadkills the currently displayed root scene- The OTP Supervisor for that scene restarts the scene with the updated code
Demo
In this demo I replace the text "World" with "Scenic", then change the color of the text to purple. Next I change the shape of the bezier line.
Note: the code running in the demo can be found at https://github.com/axelson/scenic_live_reload_demo
See also: scenic-starter-pack
Installation
Add scenic_live_reload to your list of dependencies in mix.exs:
def deps do
[
...
{:scenic_live_reload, "~> 0.2", only: :dev},
]
end
Add this configuration to your config.exs:
case Mix.env() do
:dev ->
config :exsync,
reload_timeout: 150,
reload_callback: {ScenicLiveReload, :reload_current_scene, []}
_ ->
nil
end
Then start your application with mix scenic.run (or iex -S mix), edit a file with your editor, and then you should see your change reflected.
Development
NOTE: This currently relies on a private scenic api to get the root scene which may change in future Scenic releases