Expand description
Scopes: the shared-view visibility mechanism.
A scope is a path in a tree. Every rendered element occupies one; every connection observes a small set of them. Visibility is a single line:
a connection sees an element when one of its observed scopes is comparable to the element’s, meaning one is a prefix of the other.
Both directions count, and that is what makes the relation useful: a player
at /g7/t2 sees its ancestors (/, /g7) and its descendants, while a
spectator at /g7 sees every team without anything being added to the model.
Moving up the tree is how you see more.
§The closure theorem
Imposing one rule on rendering - a child channel’s scope extends its parent’s, a user’s scope extends its channel’s - makes the property everything else depends on automatic: if I see an element, I see what it refers to.
With c the channel’s scope and u the user’s, c a prefix of u, an
observer seeing the user through some scope s comparable to u:
sis a prefix ofu: thencis also a prefix ofu, sosandcare two prefixes of the same path, hence comparable;uis a prefix ofs: thencprefixesuprefixess.
Either way the observer sees the channel. There is no runtime check to write
and no failure mode to chase, provided the builder can only ever narrow -
which is why Scope::child is the only way to make a new one.
REF: docs/design/guide-implementation.md 2
Structs§
- Scope
- A position in the visibility tree.
- Scope
Set - What one connection observes of the shared view.
- TooMany
Scopes - A connection dropped more observed scopes than
MAX_OBSERVEDallows.
Constants§
- MAX_
DEPTH - How deep a scope path may go.
- MAX_
OBSERVED - How many scopes one connection may observe at once.