Skip to content

Commit

Permalink
doc(api): signals
Browse files Browse the repository at this point in the history
  • Loading branch information
bameda committed Sep 8, 2023
1 parent 1f0ee74 commit 00ff9e2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions python/docs/signals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Signals

Signals allow certain senders to inform a set of receivers that specific actions have occurred. So a component could be able to send notification to another in a decoupled manner, minimising dependence between two or more components.

We use the Django signals dispatcher module to have signals in Taiga.

You can find more info at [Django Documentation - Signals](https://docs.djangoproject.com/en/dev/topics/signals/)


## How to implement Signals?

First, we define some elements:

- **Signal**: An object used to notify a particular event.
- **Sender**: An object that sends the signal.
- **Receiver**: A function that will be executed when a signal is dispatched.

So, the steps to use a predefined signal are:

1. Slect a predefinend signal
2. Define one or more receivers
3. Connect the receivers with their sender

Predefined signals are related to the ORM Model: pre_save, post_save, pre_delete, post_delete and m2m_changed are some of then. You can find a complete and detailed list in the [Django Documentation about predefined signals](https://docs.djangoproject.com/en/dev/ref/signals/).

If we want to use a custom signal, we follow this steps:

1. Define a signal.
2. Define one or more receivers.
3. Connect the receivers with their sender.
4. Send signals from any component.

0 comments on commit 00ff9e2

Please sign in to comment.