Sentix v1.0.3 Sentix

This module provides the Sentix interface to start a Sentix watcher and then subscribe a process afterwards. This module is deliberately small as the aim of Sentix is to provide as little behaviour on top of fswatch as possible.

Summary

Functions

Shorthand around calling start_link/3 and then simply removing the link

Starts a Sentix watcher and links it to the current process

Subscribes a process to a Sentix watcher

Functions

start(name, paths, options \\ [])
start(name :: atom, paths :: [binary], options :: Keyword.t) ::
  {:ok, pid} |
  {:error, reason :: atom | binary}

Shorthand around calling start_link/3 and then simply removing the link.

Supports all the same options and works in an identical fashion to start_link/3.

start_link(name, paths, options \\ [])
start_link(name :: atom, paths :: [binary], options :: Keyword.t) ::
  {:ok, pid} |
  {:error, reason :: atom | binary}

Starts a Sentix watcher and links it to the current process.

This function requires the name of the watcher to start up, as well as a list of paths. In addition you can provide a list of options which will be passed through to fswatch. Please view the fswatch documentation for more information as to the behaviour of these flags.

Options

  • :access - whether to receive notification of file access events.
  • :dir_only - whether to only watch directories.
  • :excludes - exclude patterns matching the provided (binary) Regex.
  • :filter - only listen for events of this type (can be a list).
  • :includes - include patterns matching the provided (binary) Regex.
  • :latency - the latency of the monitor events.
  • :monitor - specify a monitor to use, rather than the default.
  • :recursive - whether or not to recurse subdirectories.
subscribe(name, sub \\ self())
subscribe(name :: atom, sub :: atom | pid) ::
  {:ok, process :: number, subscribers :: [pid]} |
  {:error, :noproc}

Subscribes a process to a Sentix watcher.

If no process name/pid is provided, this will subscribe the calling process. If an invalid process identifier is provided, an error will be returned.