Add pubsub event system and integrate sync notifications

This commit is contained in:
thePR0M3TH3AN
2025-07-18 17:02:05 -04:00
parent 20dfc35f7e
commit 724c0b883f
4 changed files with 69 additions and 2 deletions

28
src/tests/test_pubsub.py Normal file
View File

@@ -0,0 +1,28 @@
from seedpass.core.pubsub import PubSub
def test_subscribe_and_publish():
bus = PubSub()
calls = []
def handler(arg):
calls.append(arg)
bus.subscribe("event", handler)
bus.publish("event", 123)
assert calls == [123]
def test_unsubscribe():
bus = PubSub()
calls = []
def handler():
calls.append(True)
bus.subscribe("event", handler)
bus.unsubscribe("event", handler)
bus.publish("event")
assert calls == []