LocalLiveView.Watcher (LocalLiveView v0.1.0)

Copy Markdown View Source

Automatically rebuilds the local project when it changes.

To use with Phoenix, add to watchers in config.exs:

config :my_app, MyEndpoint, watchers: [
    local_live_view: {LocalLiveView.Watcher, :start_link, []},
    # other watchers
  ]

This is automatically added by mix llv.install. When phoenix_live_reload is set up, this enables live reload for the local part of the project.

Summary

Functions

Returns a specification to start this module under a supervisor.

Builds the local project once, then starts the watcher.

Starts the watcher without the initial build.

Types

option()

@type option() :: {:dirs, [Path.t()]}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

run(opts \\ [])

@spec run([option()]) :: :ok

Builds the local project once, then starts the watcher.

This is the entry point used from the endpoint's :watchers config, so the bundle is up to date before the first request even if the local project changed while the server was down.

Options

  • :dirs — directories to watch, defaults to ["local"] relative to the project root

start_link(opts \\ [])

@spec start_link([option()]) :: GenServer.on_start()

Starts the watcher without the initial build.

Takes the same options as run/1. Use it when the local project is already built and you only want to react to later changes.