INNER CODE UNIT · Python
EventCallback
permitio/fastapi_websocket_pubsub · fastapi_websocket_pubsub/event_notifier.py:40
def EventCallback(subscription: Subscription, data: Any):
pass
class EventNotifier:
"""
A Basic Pub/Sub class using callback functions as the
Subscribers subscribe using self.subscribe, choosing topics to subscribe to
and passing a callback that will be called on a publish/notify event (with the topic and data)
Usage example:
notifier = EventNotifier()
#subscriber
notifier.subscribe( notifier.gen_subscriber_id(), ["dinner is served", "breakfast is served"],
lambda topic, data: print(f"{topic}, let's eat. We have: {data}") )