Module

pages.reactive.events

Change events, block references, and SSE swap element extraction.

Classes

ChangeEvent 3
Emitted by a store after a data mutation.

Emitted by a store after a data mutation.

Attributes

Name Type Description
scope str

Scope identifier (e.g., a document ID) so subscribers only receive events for their scope.

changed_paths frozenset[str]

The set of context paths that changed (e.g.,{"doc.content", "doc.version"}).

origin str | None

Opaque identifier for who caused this change (e.g., user ID, session ID). Used byreactive_stream to skip events originating from the same connection. Nonemeans system-initiated — always delivered.

BlockRef 4
Reference to a renderable block within a template.

Reference to a renderable block within a template.

Attributes

Name Type Description
template_name str

Kida template name.

block_name str

Block name within the template.

dom_id str | None

DOM element ID to target for OOB swap. Defaults to the block name.

Methods

target_id 0 str
DOM element ID for OOB targeting.
property
def target_id(self) -> str
Returns
str
_SSESwapElement 3
Parsed info about an HTML element with ``sse-swap``.

Parsed info about an HTML element withsse-swap.

Attributes

Name Type Description
swap_event str
dom_id str | None
inner_block str | None

Functions

_extract_sse_swap_elements 1 list[_SSESwapElement]
Extract elements with ``sse-swap`` and find their associated blocks. For each …
def _extract_sse_swap_elements(source: str) -> list[_SSESwapElement]

Extract elements withsse-swapand find their associated blocks.

For each<tag ... sse-swap="event" ...>found, captures the swap event name, elementid, and the associated {% block NAME %}.

Handles two common patterns:

  1. Block inside element (block is a child)::

    <span id="status" sse-swap="status">
        {% block toolbar_status %}v{{ doc.version }}{% endblock %}
    </span>
    
  2. Block wraps element (block is the parent)::

    {% block toolbar_status %}
    <span id="status" sse-swap="status">v{{ doc.version }}</span>
    {% endblock %}
    
Parameters
Name Type Description
source str
Returns
list[_SSESwapElement]