diff --git a/src/taipy/core/notification/__init__.py b/src/taipy/core/notification/__init__.py index 282cad383..3f6b0c3b7 100644 --- a/src/taipy/core/notification/__init__.py +++ b/src/taipy/core/notification/__init__.py @@ -13,8 +13,8 @@ Package for notifications about changes on `Core^` service entities. -The Core service generates 'Event^' objects to track changes on entities. -These events are then relayed to a 'Notifier^', which handles the dispatch +The Core service generates `Event^` objects to track changes on entities. +These events are then relayed to a `Notifier^`, which handles the dispatch to consumers interested in specific event topics. To subscribe, a consumer needs to invoke the `Notifier.register()^` method. diff --git a/src/taipy/core/notification/core_event_consumer.py b/src/taipy/core/notification/core_event_consumer.py index 963d243c4..0a75d8c76 100644 --- a/src/taipy/core/notification/core_event_consumer.py +++ b/src/taipy/core/notification/core_event_consumer.py @@ -23,17 +23,6 @@ class CoreEventConsumerBase(threading.Thread): It should be subclassed, and the `process_event` method should be implemented to define the custom logic for handling incoming events. - Attributes: - queue (SimpleQueue): The queue from which events will be consumed. - - Methods: - start(): Start the event consumer thread. - stop(): Stop the event consumer thread. - run(): The main thread execution logic that continuously consumes events from the queue - and delegates their processing to the `process_event` method. - process_event(event: Event): This method should be overridden in subclasses to define - how events are processed. - Example usage: ```python @@ -51,6 +40,10 @@ def process_event(self, event: Event): Subclasses should implement the `process_event` method to define their specific event handling behavior. + Attributes: + queue (SimpleQueue): The queue from which events will be consumed. + + """ def __init__(self, registration_id: str, queue: SimpleQueue): diff --git a/src/taipy/core/notification/notifier.py b/src/taipy/core/notification/notifier.py index 9042ec38c..20a4d0c32 100644 --- a/src/taipy/core/notification/notifier.py +++ b/src/taipy/core/notification/notifier.py @@ -92,7 +92,11 @@ def register( @classmethod def unregister(cls, registration_id: str): - """Unregister a listener.""" + """Unregister a listener. + + Parameters: + registration_id (RegistrationId^): The registration id returned by the `register` method. + """ to_remove_registration: Optional[_Registration] = None for _, registrations in cls._topics_registrations_list.items(): @@ -109,7 +113,11 @@ def unregister(cls, registration_id: str): @classmethod def publish(cls, event): - """Publish a `Core^` service event to all registered listeners whose topic matches the event.""" + """Publish a `Core^` service event to all registered listeners whose topic matches the event. + + Parameters: + event (Event^): The event to publish. + """ for topic, registrations in cls._topics_registrations_list.items(): if Notifier._is_matching(event, topic): for registration in registrations: diff --git a/src/taipy/core/notification/registration_id.py b/src/taipy/core/notification/registration_id.py index 24ec1dc5b..7d332e8f5 100644 --- a/src/taipy/core/notification/registration_id.py +++ b/src/taipy/core/notification/registration_id.py @@ -12,5 +12,4 @@ from typing import NewType RegistrationId = NewType("RegistrationId", str) -RegistrationId.__doc__ = """Type that holds a `Registration^` identifier. It can be used to instantiate a -`CoreEventConsumerBase^`.""" +RegistrationId.__doc__ = """Registration identifier. It can be used to instantiate a `CoreEventConsumerBase^`."""