From 4e93abfba91ca09848c3023b50bc31da1dcff777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Fri, 8 Sep 2023 19:11:37 +0200 Subject: [PATCH] doc(api): signals --- python/docs/signals.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 python/docs/signals.md diff --git a/python/docs/signals.md b/python/docs/signals.md new file mode 100644 index 000000000..4370d77af --- /dev/null +++ b/python/docs/signals.md @@ -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, minimizing 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. Select a predefined signal. +2. Define one or more receivers. +3. Connect the receivers with the signal. + +Predefined signals are related to the ORM Model: `pre_save`, `post_save`, `pre_delete`, `post_delete` and `m2m_changed` are some of them. 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 these steps: + +1. Define a signal. +2. Send signals from any component. +3. Define one or more receivers. +4. Connect the receivers with the signal. \ No newline at end of file