Signals API¶
This module contains the signal handlers used by Django Dispatch.
Signal Handlers¶
Django Signals¶
Django Dispatch uses the following signals from the django_broadcaster.registry module:
event_created: Dispatched when an event is createdevent_published: Dispatched when an event is published
See Registry API for more information on these signals.
Example Usage¶
from django.dispatch import receiver
from django_broadcaster.registry import event_created, event_published
@receiver(event_created)
def handle_event_created(sender, event, **kwargs):
"""Handle event created signal"""
print(f"Event created: {event.event_type}")
@receiver(event_published)
def handle_event_published(sender, event, **kwargs):
"""Handle event published signal"""
print(f"Event published: {event.event_type}")
Internal Signal Flow¶
When an OutboxEvent is created, the post_save signal is triggered
The handle_outbox_event_signals function receives this signal
If the event is new (created=True), it dispatches the event_created signal
If the event’s status is PUBLISHED, it dispatches the event_published signal
This signal flow allows for decoupled components to react to events being created or published.