A shared canvas on Issho: the canvas's graph is a document of an Issho room, the canvas's LiveView is one of the room's sessions, and Issho is the room's people and their cursors.
<.canvas id="schema" graph={@graph} live={{MyApp.Issho, "schema:42"}} user={@current_user} />The first canvas to open the room's document gives it its graph, its
rules and its on_change; the others get the document as it is. Each
change goes to the document's authority, which checks the rules,
applies it, asks on_change (once, whoever made it), and only then
sends it to every canvas of the room. The document lasts as long as a
canvas has it open: your app's tables, which on_change writes, are
the truth, and the next canvas starts from the graph you give it.
change/3 makes your app's own change, from anywhere (a job, another
LiveView), on a canvas someone has open.
Summary
Functions
Makes your app's own change on a shared canvas: the way of a person's
(the rules, on_change), to everyone in the room, and not a person's to
undo (by is nil). Gives :ok, {:error, reason}, or
{:error, :not_running} when no canvas has the room open (then change
your own copy, in your database).
The graph of a shared canvas as its room has it, or nil when no canvas has it open.
Functions
@spec change(atom(), String.t(), Hakushi.Change.t()) :: :ok | {:error, term()}
Makes your app's own change on a shared canvas: the way of a person's
(the rules, on_change), to everyone in the room, and not a person's to
undo (by is nil). Gives :ok, {:error, reason}, or
{:error, :not_running} when no canvas has the room open (then change
your own copy, in your database).
@spec graph(atom(), String.t()) :: Hakushi.Graph.t() | nil
The graph of a shared canvas as its room has it, or nil when no canvas has it open.