Macaw.Live.Mounted (macaw_live v0.1.0)

Copy Markdown View Source

The render-stable part of a mounted surface, in the socket's assigns as @macaw (spec/01 §3): what a template reads.

surfaces maps each mounted surface's name to %{chrome: %{open:, close:}, cells:}: its chrome (Macaw.Surface.chrome/2) and its cells in reading order, each %{instance:, classes:, init:}, init the cell's first proved render (its module, kind, assigns, sequence and drawn outcome). It changes only when a surface is mounted, remounted or unmounted, and a surface's chrome when the viewer's theme changes its mw-theme-<name> class (spec/06 §2.4); every later change reaches a cell's component directly (Phoenix.LiveView.send_update/3), so an event never re-renders the surface's chrome or touches a cell it doesn't affect.

shortcuts is the page's shortcut registry as the dialog lists it (spec/05 §6): its active entries with the viewer's preference applied and the ones it turned off (Macaw.Live.Shortcuts). It changes when a surface is mounted or unmounted and when the viewer changes the preference.

sheets is each mounted surface's registered stylesheets in mount order, {name, %{layout:, theme:, cells:}}, each a path, which Macaw.Live.stylesheets/1 links (spec/06 §2.3). It changes only when a surface is mounted or unmounted, and a surface's theme path when the viewer's theme changes (spec/06 §2.4).

stream is a connected page's binary stream as each surface's wrapper names it, %{topic:, token:} (Macaw.Live.Stream, spec/05 §9.3), or nil before the socket connects. It is set by the first connected mount and never changes.

limited is whether the visit's last client event was over its event budget and dropped (spec/01 §5.1, Macaw.Live.Visit.Budget), so a template can tell the visitor they are limited. It changes only when it turns: true at the first event dropped, false at the next one admitted.

Summary

Types

One cell as the template places it.

t()

The render-stable surfaces, by name.

Types

cell()

@type cell() :: %{instance: String.t(), classes: String.t(), init: map()}

One cell as the template places it.

t()

@type t() :: %Macaw.Live.Mounted{
  limited: boolean(),
  sheets: [{String.t(), Macaw.Live.Assets.sheets()}],
  shortcuts: %{
    active: [Macaw.Live.Shortcuts.entry()],
    off: [Macaw.Live.Shortcuts.entry()]
  },
  stream: %{topic: String.t(), token: String.t()} | nil,
  surfaces: %{
    required(String.t()) => %{chrome: Macaw.Surface.chrome(), cells: [cell()]}
  }
}

The render-stable surfaces, by name.