Volt.HMR (Volt v0.14.12)

Copy Markdown View Source

Public helpers for broadcasting Volt HMR messages.

These functions are intended for packages that compose Volt's dev server but own additional source graphs, such as static-site generators. They expose the same websocket protocol used internally by Volt.Watcher without requiring callers to reach into Volt's registry implementation.

Summary

Functions

Broadcast an HMR message to all connected clients.

Broadcast an error payload for a source path.

Broadcast a full page reload request for a changed path.

Invalidate Volt's dev compilation state for a source file without broadcasting.

Broadcast a style-only update for a changed stylesheet path.

Broadcast an update for a changed path.

Functions

broadcast(type, payload \\ nil)

@spec broadcast(:update | :error | :ping | :pong, term()) :: :ok

Broadcast an HMR message to all connected clients.

error(path, reason)

@spec error(String.t(), term()) :: :ok

Broadcast an error payload for a source path.

full_reload(path)

@spec full_reload(String.t()) :: :ok

Broadcast a full page reload request for a changed path.

invalidate_file(path)

@spec invalidate_file(String.t()) :: :ok

Invalidate Volt's dev compilation state for a source file without broadcasting.

style_update(path)

@spec style_update(String.t()) :: :ok

Broadcast a style-only update for a changed stylesheet path.

update(path, changes, opts \\ [])

@spec update(String.t(), [atom() | String.t()], keyword()) :: :ok

Broadcast an update for a changed path.