ExFSWatch
A file change watcher wrapper based on fs
System Support
Just like fs
- Mac fsevent
- Linux inotify
- Windows inotify-win (untested)
NOTE: On Linux you need to install inotify-tools.
Usage
Put exfswatch in the deps and application part of your mix.exs
defmodule Excellent.Mixfile do
use Mix.Project
def project do
...
end
def application do
[applications: [:exfswatch, :logger]]
end
defp deps do
[
{ :exfswatch, "~> 0.1.0", only: :test },
]
end
...
endwrite lib/monitor.ex
defmodule Monitor do
use ExFSWatch, dirs: ["/tmp/fswatch"]
def callback(:stop) do
IO.puts "STOP"
end
def callback(file_path, events) do
IO.inspect {file_path, events}
end
endExecute in iex
iex > Monitor.startList Events from Backend
iex > ExFSWatch.known_eventsTODO
- GenEvent mode
- Unit Testing