MobDev.Server.WatchWorker (mob_dev v0.5.8)

Copy Markdown View Source

GenServer that runs the mob.watch loop inside the mob.server process.

Polls lib/**/*.ex for changes every 500ms. When files change it debounces, recompiles, and hot-pushes changed modules to all connected device nodes via Erlang dist — same logic as mix mob.watch but driven from the dashboard UI instead of a terminal.

Events broadcast to the "watch" PubSub topic: {:watch_status, :watching | :idle} {:watch_push, %{pushed: n, failed: [...], nodes: [...], files: [...]}}

Summary

Functions

Returns a specification to start this module under a supervisor.

Start watching. Idempotent — safe to call when already watching.

Returns %{watching: bool, nodes: [node()], last_push: map | nil}.

Stop watching.

Subscribe the calling process to watch PubSub events.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(_)

@spec start_link(term()) :: GenServer.on_start()

start_watching()

@spec start_watching() :: term()

Start watching. Idempotent — safe to call when already watching.

status()

@spec status() :: map()

Returns %{watching: bool, nodes: [node()], last_push: map | nil}.

stop_watching()

@spec stop_watching() :: term()

Stop watching.

subscribe()

@spec subscribe() :: :ok | {:error, term()}

Subscribe the calling process to watch PubSub events.