The mutable cell behind a document tree.
Rendering a template is a long sequence of in-place edits - nodes are
removed, duplicated and re-parented while operations are evaluated - and
references to a node have to stay valid across all of them. Threading a
persistent tree through every one of those edits would obscure the algorithm
it implements, so the tree lives in a mutable store instead and nodes are
{store, id} pairs pointing into it.
The store is backed by the process dictionary: a render happens in a single
process, so this needs neither an extra process nor an ETS table, and the
data disappears with the process even if drop/1 is never called. Because of
that a document cannot be shared across processes - build it, edit it and
serialise it in the same one.
Summary
Functions
Removes a key.
Discards everything the store holds.
Reads a key as an {:ok, value} / :error pair.
Reads a key, raising when it is not set.
Reads a key, returning default when it is not set.
Increments an integer counter and returns its new value.
Creates an empty store.
Writes a key.
Updates a key, starting from default when it is not set.
Types
Functions
Removes a key.
@spec drop(t()) :: :ok
Discards everything the store holds.
Optional - the data is process local and dies with the process - but worth calling in a long lived process that renders many documents.
Reads a key as an {:ok, value} / :error pair.
Reads a key, raising when it is not set.
Reads a key, returning default when it is not set.
Increments an integer counter and returns its new value.
Used to hand out node ids, which must stay unique for the life of a tree.
@spec new() :: t()
Creates an empty store.
Writes a key.
Updates a key, starting from default when it is not set.