Dev-only GenServer that watches every source file contributing to an RPC router — the router module itself and every handler module — and triggers recompilation when one of them changes.
Requires the optional :file_system dep. If it is not loaded, init/1
returns :ignore — the process is never started — after emitting a warning.
This watcher is Phoenix-specific: without an :endpoint or :on_change
option there is nothing to do when a file changes. For non-Phoenix apps the
Mix.Tasks.Compile.ElixirTsRpc compiler already regenerates the TypeScript
client on each Elixir recompile; you do not need this watcher.
Usage
# lib/my_app/application.ex (Phoenix projects only)
children = [
# …
{RpcElixir.Watcher, router: MyApp.Router, endpoint: MyAppWeb.Endpoint}
]Options
:router(required) — the RPC router module.:endpoint— a Phoenix endpoint; the watcher callsPhoenix.CodeReloader.reload/1on each relevant change.:on_change—{mod, fun, args}invoked on change. Takes precedence over:endpointwhen both are given.:debounce_ms— milliseconds to coalesce rapid file events before triggering a reload. Defaults to200.
Restart expectations
RpcElixir.Watcher traps exits so that it can clean up on supervisor
shutdown. The linked FileSystem process is started inside init/1; if it
crashes unexpectedly the watcher will also terminate and the supervisor is
expected to restart the pair.
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.