Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/new_example/config/config.exs.eex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ config :<%= @app %>, :viewport, %{
]
}

# Configure reload callback of ExSync so that we are notified when a file is changed
config :exsync,
reload_callback: {GenServer, :call, [<%= @mod %>.Component.Nav, :reload_current_scene]}

# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
Expand Down
6 changes: 6 additions & 0 deletions templates/new_example/lib/components/nav.ex.eex
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ defmodule <%= @mod %>.Component.Nav do
ViewPort.set_root(vp, scene)
{:stop, state}
end

def handle_call(:reload_current_scene, _, state) do
pid = Process.whereis(:scenic)
Process.exit(pid, :kill)
{:reply, nil, state}
end
end
1 change: 1 addition & 0 deletions templates/new_example/mix.exs.eex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ defmodule <%= @mod %>.MixProject do
[
{:scenic, "~> 0.9"},
{:scenic_driver_glfw, "~> 0.9"},
{:exsync, git: "https://github.com/falood/exsync.git", ref: "922622c"},

# These deps are optional and are included as they are often used.
# If your app doesn't need them, they are safe to remove.
Expand Down