MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / EventBus

Class EventBus

event_bus.py:7–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6
7class EventBus:
8 def __init__(self):
9 self._listeners: defaultdict[Type[BaseEvent], list[Callable[[Any], None]]] = defaultdict(list)
10
11 def subscribe(self, event_type: Type[BaseEvent], listener: Callable[[Any], None]):
12 """Registers a listener for a specific event type."""
13 self._listeners[event_type].append(listener)
14
15 def publish(self, event: BaseEvent):
16 """Publishes an event to all registered listeners."""
17 for listener in self._listeners[type(event)]:
18 listener(event)

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected