INNER CODE UNIT · Python
subscribe
permitio/fastapi_websocket_pubsub · fastapi_websocket_pubsub/event_notifier.py:92
async def subscribe(
self,
subscriber_id: SubscriberId,
topics: Union[TopicList, ALL_TOPICS],
callback: EventCallback,
channel: Optional[RpcChannel] = None,
) -> List[Subscription]:
"""
Subscribe to a set of topics.
Once a notification (i.e. publish) of a topic is received the provided callback function will be called (with topic and data)
Args:
subscriber_id (SubscriberID): A UUID identifying the subscriber
topics (TopicList, ALL_TOPICS): A list of topic to subscribe to (Each topic is saved in a separate subscription)
ALL_TOPICS can be passed to subscribe to everything (all current and future topics)
callback (Callable): the callback function to call upon a publish event
channel (RpcChannel): Optional channel to handle on the registered restrictions