Created
October 29, 2016 11:32
-
-
Save thbar/1161034c641d32271419bf2e065cc071 to your computer and use it in GitHub Desktop.
Live code reloading with Elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mix run --no-halt reloading.exs | |
# in music.exs, put: | |
# | |
# defmodule Music do | |
# def version do | |
# "3" | |
# end | |
# end | |
# | |
# then tweak it and save, Music will be reloaded dynamically | |
Code.compiler_options(ignore_module_conflict: true) | |
defmodule Monitor do | |
# relies on https://github.com/falood/exfswatch/pull/9 for --latency support | |
use ExFSWatch, dirs: ["music.exs"], listener_extra_args: "--latency=0.0" | |
def callback(_file_path, _events) do | |
Code.eval_file("music.exs") | |
IO.inspect Music.version | |
end | |
end | |
Monitor.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment