Module

pages.reactive.stream

Reactive SSE stream that auto-pushes re-rendered blocks.

Functions

_context_builder_arity 1 int
Detect whether context_builder accepts a positional changed_paths arg.
def _context_builder_arity(fn: _ContextBuilder) -> int
Parameters
Name Type Description
fn _ContextBuilder
Returns
int
reactive_stream 8 EventStream
Create an SSE EventStream that auto-pushes re-rendered blocks. Subscribes to t…
def reactive_stream(bus: ReactiveBus, *, scope: str, index: DependencyIndex, context_builder: _ContextBuilder, origin: str | None = None, connection: ConnectionInfo | None = None, on_disconnect: Callable[[str, ConnectionInfo | None], None] | None = None, kida_env: Any = None) -> EventStream

Create an SSE EventStream that auto-pushes re-rendered blocks.

Subscribes to theReactiveBusfor the given scope. When a ChangeEventarrives, looks up affected blocks in the DependencyIndex and yields them as Fragmentobjects. The chirp SSE layer handles rendering via the app's kida env.

Parameters
Name Type Description
bus ReactiveBus

The reactive event bus to subscribe to.

scope str

Scope key (e.g., document ID).

index DependencyIndex

Dependency index mapping paths to blocks.

context_builder _ContextBuilder

Callable that returns the current context dict. May accept zero arguments (original API) or one argument (frozenset[str]of changed paths for selective queries).

origin str | None

Identity of this connection (e.g., user/session ID). Events whoseorigin matches are skipped — the client that caused the change doesn't need to be notified of it. Nonedisables origin filtering.

Default:None
connection ConnectionInfo | None

Optional subscriber identity. Enables audience filtering and presence tracking on the bus.

Default:None
on_disconnect Callable[[str, ConnectionInfo | None], None] | None

Optional callback invoked when this subscriber exits. Receives(scope, connection).

Default:None
kida_env Any

Deprecated — rendering is handled by the SSE response layer. Accepted for backwards compatibility.

Default:None
Returns
EventStream