Classes
ReactiveBus
5
▼
Broadcast channel for data change events.
Thread-safe. Each call to ``subscribe(scope)`` returns …
ReactiveBus
5
▼
Broadcast channel for data change events.
Thread-safe. Each call tosubscribe(scope)returns an async
iterator that yieldsChangeEvents for that scope. When
emit()is called, the event is placed into every matching
subscriber's queue.
Modeled on chirp'sToolEventBusbut scoped per-key.
Methods
emit_sync
1
▼
Broadcast a change event synchronously (from any thread).
Uses ``put_nowait`` …
emit_sync
1
▼
def emit_sync(self, event: ChangeEvent) -> None
Broadcast a change event synchronously (from any thread).
Usesput_nowaitso it never blocks. Drops the event for
a subscriber if its queue is full (back-pressure).
Parameters
| Name | Type | Description |
|---|---|---|
event |
— |
emit
1
▼
Broadcast a change event (async version).
async
emit
1
▼
async def emit(self, event: ChangeEvent) -> None
Parameters
| Name | Type | Description |
|---|---|---|
event |
— |
subscribe
1
AsyncIterator[ChangeEven…
▼
Subscribe to change events for a specific scope.
Yields ``ChangeEvent`` object…
async
subscribe
1
AsyncIterator[ChangeEven…
▼
async def subscribe(self, scope: str) -> AsyncIterator[ChangeEvent]
Subscribe to change events for a specific scope.
YieldsChangeEventobjects as they are emitted. The
subscription is automatically cleaned up when the iterator
exits (client disconnects).
Parameters
| Name | Type | Description |
|---|---|---|
scope |
— |
Returns
AsyncIterator[ChangeEvent]
close
1
▼
Signal subscribers to stop.
If *scope* is given, only close that scope's subsc…
close
1
▼
def close(self, scope: str | None = None) -> None
Signal subscribers to stop.
If scope is given, only close that scope's subscribers. Otherwise close all.
Parameters
| Name | Type | Description |
|---|---|---|
scope |
— |
Default:None
|
Internal Methods 1 ▼
__init__
0
▼
__init__
0
▼
def __init__(self) -> None