Volt.HMR.Message (Volt v0.14.12)

Copy Markdown View Source

JSON message sent over the HMR WebSocket protocol.

Uses JSONCodec for struct<->JSON (de)serialization. Jason is still used for the final binary encoding of the dumped map.

Wire types

  • update — an HMR update payload (path, changes, optional boundary, timestamp)
  • error — a build/runtime error to surface in the overlay
  • ping — heartbeat sent by the browser client
  • pong — heartbeat reply from the server

Summary

Functions

Decodes a JSON string into this struct.

Decodes a JSON string into this struct, raising on failure.

Dumps this struct into JSON-shaped data, respecting JSON field names.

Builds this struct from a decoded JSON map.

Builds this struct from a decoded JSON map, raising on failure.

Returns a JSON Schema-compatible schema map.

Returns a JSON Schema-compatible schema map.

Converts this struct into a JSON-shaped map.

Types

t()

@type t() :: %Volt.HMR.Message{
  payload: term() | nil,
  type: :update | :error | :ping | :pong
}

Functions

decode(json)

Decodes a JSON string into this struct.

decode!(json)

Decodes a JSON string into this struct, raising on failure.

dump(struct)

Dumps this struct into JSON-shaped data, respecting JSON field names.

from_map(map)

Builds this struct from a decoded JSON map.

from_map!(map)

Builds this struct from a decoded JSON map, raising on failure.

json_schema()

Returns a JSON Schema-compatible schema map.

schema()

Returns a JSON Schema-compatible schema map.

to_map(struct)

Converts this struct into a JSON-shaped map.