Skip to main content

Module bus

Module bus 

Source
Expand description

FRAME-12: the bus — what the host hands every mounted component, whatever drew it (the rhx runtime, a module written by hand, FRAME-13’s Svelte): one Bus per page, one Member per mounted component.

  • call(method, params) — through the page’s one socket, refused before it when the component’s uses does not name the method; FRAME-37: its stream gathered into one Answer by answer_sink — what rhx’s call(method, params, "fold") folds and a module’s bus.call resolves;
  • live(spec) — the page’s live collection for that spec (the whole spec: snapshot, params, changes, changes params, key, folds), shared with every other reader of it, rhx or not; its methods held to uses; FRAME-19: a module’s (Member::follow) held by its when and its param changes coalesced by its debounce_ms, as rhx’s are;
  • emit(topic, data) / on(topic, f) — page-wide, topics bare strings matched whole, plexus. the host’s own (a component’s emit under it is refused); a member never hears its own emit;
  • FRAME-53: a sticky topic — Member::emit_sticky (and the host’s Bus::say_sticky, plexus.booted) keeps the topic’s last event on the bus, one per topic; a later emit on it, sticky or not, replaces it, and it goes when the member that said it leaves (a remount says it again; the host’s own are never cleared). Member::on_last hears the kept event at once (in the bus’s turn: now, when nothing is under way or held), then as Member::on; Bus::last answers it — only what has been delivered. A topic never emitted sticky is kept for no one;
  • GAMMA-6: stream(method, params, on, done) — a call whose items reach the member one by one as they arrive, then its end (StreamEnd); held to uses as call is; Streaming::stop closes it on the wire, and a member that leaves closes every stream it holds;
  • navigate(route); slots_set(layout, slot, component, version?) — ui.slots.set, a call like any other, held to uses; FRAME-29: a section a mark binds (data-component) is refused bound before it.

Delivery waits its turn. Everything the bus hands out — each listener’s event, each deferred callback (Bus::defer, a module’s subscribe) — goes through one queue, first in first out, and is run only when nothing of the host’s is under way: an emit made inside a delivery, or inside an rhx fold (Bus::hold around it), is heard after the one under way has reached every listener. Nothing is re-entered, so no borrow of the host’s is ever held across a component.

FRAME-36: keys(decls) — a component’s shortcuts into the page’s one registry (crate::keys::Keys), held until the answer is dropped or the member leaves.

A member that Member::leaves (its component unmounted or swapped out) hears nothing more and reaches no one.

Structs§

Answer
FRAME-37: a call’s answer, whole, once its stream ended — ok when it ended with no in-band error / refused event, no refusal, no failure and no drop; events its data events in order (each a map with type); message the error’s, refusal’s or failure’s words (an in-band one’s message, else its reason), or DISCONNECTED for a drop, when not ok.
Bus
The page’s one bus (a handle: clones are the same bus).
Hold
Bus::hold’s guard: dropping it lets the queue run.
Listening
A listener held: dropping it stops it.
Member
One mounted component’s side of the bus (a handle).
Streaming
GAMMA-6: a stream a member opened (Member::stream); stop ends it. Dropping it stops nothing: the stream lives until it ends, it is stopped, or its member leaves.

Enums§

BusRefusal
What the bus refuses a member, before anything reaches the socket.
StreamEnd
GAMMA-6: how a stream (Member::stream) ended — once, last.
StreamEvent
GAMMA-6: one item of a stream as a member hears it — each data event’s content, then its end.

Constants§

DISCONNECTED
FRAME-37: what message says when the socket dropped before the answer.
RESERVED
The prefix of the host’s own topics.

Traits§

BusHost
What the bus needs of the host: the socket, the live cache, the router and the live version.

Functions§

answer_sink
FRAME-37: a sink that gathers a call’s stream and hands done its Answer once, when the stream ends (Done, a refusal, or the socket dropping under it). Nothing here sends anything: a call is sent once.
covers
GAMMA-5: whether uses holds method — named exactly, or under an open entry’s prefix by whole segments (things.* holds things.list and things.bins.count, never things itself or thingsx.list). An entry that is neither (bare *, things*) holds nothing.
is_exact
GAMMA-5: whether entry names one method exactly — no * in it.
open_prefix
GAMMA-5: the prefix of an open uses entry — things.* → things, dyn.peer.* → dyn.peer — a component calling, at run time, any method whose name begins with that prefix’s whole segments. None for an exact method, and for anything else holding a *: bare * (never an entry), things*, things.*.list, an empty segment.