zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

README.md (2009B)


      1 ExSync
      2 ======
      3 
      4 Yet another Elixir reloader.
      5 
      6 ## System Support
      7 
      8 ExSync deps on [FileSystem](https://github.com/falood/file_system)
      9 
     10 ## Usage
     11 
     12 1. Create a new application:
     13 
     14         mix new my_app
     15 
     16 2. Add exsync to your `mix.exs` dependencies:
     17 
     18 ```elixir
     19 def deps do
     20   [ {:exsync, "~> 0.2", only: :dev} ]
     21 end
     22 ```
     23 
     24 3. (If runing Elixir < 1.4) Start your application the usual way, e.g., `iex -S mix`, then:
     25 
     26 ```elixir
     27 ExSync.start()
     28 ```
     29 
     30 4. (Alternative) To always start ExSync when available, add the following to an application's `start/2`:
     31 
     32 ```elixir
     33 defmodule MyApp do
     34   use Application
     35 
     36   def start(_type, _args) do
     37     import Supervisor.Spec, warn: false
     38 
     39     case Code.ensure_loaded(ExSync) do
     40       {:module, ExSync = mod} ->
     41         mod.start()
     42       {:error, :nofile} ->
     43         :ok
     44     end
     45 
     46     # ... rest of your applications start script.
     47   end
     48 end
     49 ```
     50 
     51 ## Usage for umbrella project
     52 
     53 1. Create an umbrella project
     54 
     55         mix new my_umbrella_app --umbrella
     56 
     57 2. Add exsync to your `mix.exs` dependencies:
     58 
     59 ```elixir
     60 def deps do
     61   [ {:exsync, "~> 0.2", only: :dev} ]
     62 end
     63 ```
     64 
     65 3. start your umbrella project with `exsync` task
     66 
     67         iex -S mix exsync
     68 
     69 ## Config
     70 
     71 1. add your own dirs to monitor, if you want monitor `priv` dir, use such config:
     72 
     73 ```elixir
     74 config :exsync, :addition_dirs, ["/priv"]
     75 ```
     76 
     77 2. add your own extensions
     78 
     79 ```elixir
     80 config :exsync, :extensions, [".erl", ".hrl", ".ex", ".tpl"]
     81 ```
     82 
     83 3. Add an [MFA](https://codereviewvideos.com/blog/what-is-mfa-in-elixir/) callback so that your code can implement special handling when files are done reloading.
     84 
     85 Example config:
     86 ```elixir
     87 config :exsync,
     88   reload_timeout: 75,
     89   reload_callback: {MyApp.MyModule, :handle_reload, [42]}
     90 ```
     91 
     92 This will call your `MyApp.MyModule` module after there have been no new reloads detected after 75ms. Specifically it will make a call like `MyApp.MyModule.handle_reload(42)` (any items you put in the list will be added as arguments to [`Task.start/3`](https://hexdocs.pm/elixir/Task.html#start/3))