The owner of one surface instance's :shared state (spec/04 §4), across every viewer's
process: a wall display's selection, set by anyone watching it, seen by everyone. New:
visualize's shared board state lived in Visualize.Board.Server, not carried over.
- Its key (
key/2) is the surface's name, the env'sshared_key:(the host's instance, such as a tenant,nilby default) and the digest of the validated surface, so two versions of a surface never share an owner. - It is registered through
owners:and started under<live>.Owners,:transient, by the first page that mounts the instance (ensure/3); racing pages take the one started first. It holds aMacaw.Stateof the validated surface, starting at its initial values, and uses only its:sharednames. - Viewers join its edge at mount (
Macaw.Live.Edge.join/3) and put its values into their own state before their first render. It publishes through the notification behavior on its topic (topic/2),{:macaw_live, :edge, key, seq, values}, the names that changed. - A viewer's event is applied by the viewer to its other scopes and sent here
(
apply/2, a cast). The owner applies events in arrival order withscopes: [:shared]and publishes what changed; every viewer, the sender among them, takes the change from its mirror. No viewer applies a:sharedwrite itself, so every viewer sees the owner's order. - Faults of an event (a value its declaration refuses) change nothing and are
reported in
info/1. - It lives while a viewer is joined and
linger:(60,000 ms) after the last leaves, so a wall display that reloads finds its state. - A crashed owner is restarted by
Ownersat its initial values; its viewers' mirrors rejoin and take them whole.
Summary
Functions
A viewer's event sent to the owner, which applies it with scopes: [:shared] in arrival
order: :ok, never waiting. legal is the current legal values of the values_from
states it writes, by name, as the viewer read them (Macaw.Surface.legal/2), and the
owner judges those writes against them (Macaw.State.apply/3's legal:): %{} for an
event that writes none, and a values_from write sent without its values is refused.
Returns a specification to start this module under a supervisor.
The owner of key under the supervisor live, started when none runs: {:ok, pid},
the one started first when two pages race, or {:error, reason}. opts: validated:
(the validated surface), host: (the host's values for its initials), clock:, and
linger: (60,000 ms).
The owner's present state: its key, sequence, :shared values, the viewers joined and
the faults of the events it refused, in arrival order. {:ok, info}, or {:error, reason}.
The key of a surface instance's owner: its name, the host's shared_key: and the
digest of the validated surface.
A viewer leaves the owner: :ok, never waiting.
The names of a state's :shared sources, in name order: [] for a surface with none,
which has no owner.
The topic an owner publishes on, "macaw:<live>:shared:<digest>" (spec/03 §7).
The owner of key under the supervisor live, or nil when none runs.
Types
Functions
@spec apply(pid(), Macaw.Data.Event.t(), map()) :: :ok
A viewer's event sent to the owner, which applies it with scopes: [:shared] in arrival
order: :ok, never waiting. legal is the current legal values of the values_from
states it writes, by name, as the viewer read them (Macaw.Surface.legal/2), and the
owner judges those writes against them (Macaw.State.apply/3's legal:): %{} for an
event that writes none, and a values_from write sent without its values is refused.
Returns a specification to start this module under a supervisor.
See Supervisor.
The owner of key under the supervisor live, started when none runs: {:ok, pid},
the one started first when two pages race, or {:error, reason}. opts: validated:
(the validated surface), host: (the host's values for its initials), clock:, and
linger: (60,000 ms).
The owner's present state: its key, sequence, :shared values, the viewers joined and
the faults of the events it refused, in arrival order. {:ok, info}, or {:error, reason}.
@spec key(Macaw.Surface.Validated.t(), term()) :: key()
The key of a surface instance's owner: its name, the host's shared_key: and the
digest of the validated surface.
A viewer leaves the owner: :ok, never waiting.
@spec names(Macaw.State.t()) :: [String.t()]
The names of a state's :shared sources, in name order: [] for a surface with none,
which has no owner.
The topic an owner publishes on, "macaw:<live>:shared:<digest>" (spec/03 §7).
The owner of key under the supervisor live, or nil when none runs.