Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/axelson/scenic_live_reload

Live reload your scenic scenes, based on exsync
https://github.com/axelson/scenic_live_reload

Last synced: 2 months ago
JSON representation

Live reload your scenic scenes, based on exsync

Awesome Lists containing this project

README

        

# 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](https://github.com/axelson/exsync) to watch the file system
* When you edit a file with your editor, exsync recompiles and reloads that beam file
* `exsync` notifies `scenic_live_reload` that files were reloaded
* `scenic_live_reload` kills 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.

[![Screencast Demo](./demo.gif)](https://raw.githubusercontent.com/axelson/scenic-starter-pack/master/demo.gif)

Note: the code running in the demo can be found at https://github.com/axelson/scenic_live_reload_demo

See also: [scenic-starter-pack](https://github.com/axelson/scenic-starter-pack)

# Installation

Add `scenic_live_reload` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
...
{:scenic_live_reload, "~> 0.3", 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_scenes, []}

_ ->
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