ex_watcher

Build Status

An Elixir file change watcher based on fs

System Support

Just like fs

NOTE: On Linux you need to install inotify-tools ./scripts/install_inotify.sh.

Usage

Put ex_watcher in the deps and application part of your mix.exs

defmodule MyProject.Mixfile do
  use Mix.Project

  # ...

  def application do
    [applications: [:exfswatch, :logger]]
  end

  defp deps do
    [
      {:exfswatch, "~> 0.1.0"},
    ]
  end
  
  # ...
end

write lib/monitor.ex

defmodule Monitor do
  use ExWatcher.Watcher, dirs: ["/tmp/fswatch"]

  def callback(:stop) do
    IO.puts("STOP")
  end

  def callback(file_path, events) do
    IO.inspect({file_path, events})
  end
end

Execute in iex

iex > Monitor.start()

List Events from Backend

iex > ExWatcher.known_events()

Installation

If available in Hex, the package can be installed as:

  1. Add ex_watcher to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:ex_watcher, "~> 0.1.0"}]
end
```
  1. Ensure ex_watcher is started before your application:
```elixir
def application do
  [applications: [:ex_watcher]]
end
```