Skip to content

Notifier class

A class for managing event registrations and publishing a Taipy application events.

Methods

publish() classmethod

publish(event: Event) -> None

Publish a Taipy application event to all registered listeners whose topic matches the event.

Parameters:

Name Type Description Default
event Event

The event to publish.

required

register() classmethod

register(
    entity_type: Optional[EventEntityType] = None,
    entity_id: Optional[str] = None,
    operation: Optional[EventOperation] = None,
    attribute_name: Optional[str] = None,
) -> Tuple[str, SimpleQueue]

Register a listener for a specific event topic.

The topic is defined by the combination of an optional entity type, an optional entity id, an optional operation, and an optional attribute name. The purpose is to be as flexible as possible. For example, we can register to:

  • All scenario creations
  • A specific data node update
  • A sequence submission
  • A Scenario deletion
  • Job failures

Standard usage

registration_id, registered_queue = Notifier.register(
    entity_type=EventEntityType.SCENARIO,
    operation=EventOperation.CREATION
)

Parameters:

Name Type Description Default
entity_type Optional[EventEntityType]

If provided, the listener will be notified for all events related to this entity type. Otherwise, the listener will be notified for events related to all entity types.
The possible entity type values are defined in the EventEntityType enum. The possible values are:

  • CYCLE
  • SCENARIO
  • SEQUENCE
  • TASK
  • DATA_NODE
  • JOB
  • SUBMISSION
None
entity_id Optional[str]

If provided, the listener will be notified for all events related to this entity. Otherwise, the listener will be notified for events related to all entities.

None
operation Optional[EventOperation]

If provided, the listener will be notified for all events related to this operation. Otherwise, the listener will be notified for events related to all operations.
The possible operation values are defined in the EventOperation enum. The possible values are:

  • CREATION
  • UPDATE
  • DELETION
  • SUBMISSION
None
attribute_name Optional[str]

If provided, the listener will be notified for all events related to this entity's attribute. Otherwise, the listener will be notified for events related to all attributes.

None

Returns:

Type Description
Tuple[str, SimpleQueue]

A tuple containing the registration id and the event queue.

unregister() classmethod

unregister(registration_id: str) -> None

Unregister a listener.

Standard usage

registration_id, registered_queue = Notifier.register(
    entity_type=EventEntityType.CYCLE,
    entity_id="CYCLE_cycle_1",
    operation=EventOperation.CREATION
)

Notifier.unregister(registration_id)

Parameters:

Name Type Description Default
registration_id `RegistrationId`

The registration id returned by the register method.

required