Skip to content
A file watcher for Elixir language
Elixir
Latest commit c32c946 Feb 23, 2016 @ryo33 Call callbacks safely
Failed to load latest commit information.
config
lib
test
.gitignore
.travis.yml
LICENSE
README.md
mix.exs
mix.lock

README.md

Fwatch

A file watcher for Elixir.
Build Status

Installation

The package can be installed as:

  1. Add fwatch to your list of dependencies in mix.exs:

    def deps do
      [{:fwatch, "~> 0.1.0"}]
    end
    
  2. Ensure fwatch is started before your application:

    def application do
      [applications: [:fwatch]]
    end
    

Usage

Examples

# Watch a file and registers a callback
Fwatch.watch_file("filename", fn path, events ->
  if :modified in events do
    IO.puts("#{path} is modified")
  end
end)
# Watch multiple files and registers a callback
Fwatch.watch_file(["filename1", "filename2"], callback)
# Watch a directory and registers a callback
Fwatch.watch_dir("dirname", callback)
# Watch multiple directories and registers a callback
Fwatch.watch_dir(["dirname1", "dirname2"], callback)

See Lists Events from Backend for details of events.

You can also use regular expressions as a filename or dirname like this:
Fwatch.watch_file(~r"/User/tmp/.*", callback)

Something went wrong with that request. Please try again.