Trebejo.File (Trebejo v1.0.0)

Copy Markdown View Source

File system watching backed by Apero.File.Watcher and Arrea.WorkerSupervisor.

These operations were moved from Apero.File (v2.x) to Trebejo.File (v1.x) because they depend on Arrea.WorkerSupervisor for process supervision. The pure file operations remain in Apero.File with no Arrea dependency.

Example

iex> {:ok, _pid} = Trebejo.File.watch(["/tmp"], fn events ->
...>   IO.inspect(events, label: "changed")
...> end, debounce_ms: 50)

Summary

Functions

Stops a file watcher by PID.

Starts watching dirs for file system changes.

Functions

unwatch(pid)

@spec unwatch(pid()) :: :ok

Stops a file watcher by PID.

watch(dirs, callback, opts \\ [])

@spec watch([binary()], ([{binary(), [atom()]}] -> any()), keyword()) ::
  {:ok, pid()} | {:error, term()}

Starts watching dirs for file system changes.

Calls callback with a list of {path, events} tuples after each debounce window.

Options

  • :debounce_ms — debounce delay in ms (default: 100)
  • :name — optional name for the watcher process

Returns {:ok, pid}.