Commit e90428a9d0b8dc4a4acdee9545a8f26fe3acdfd6

Authored by Lucas Kanashiro
1 parent 8570d70e

Update doc of plugins signals

Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
Showing 1 changed file with 9 additions and 3 deletions   Show diff stats
docs/source/plugindev.rst
@@ -9,6 +9,8 @@ Getting Started @@ -9,6 +9,8 @@ Getting Started
9 9
10 Signals 10 Signals
11 ---------- 11 ----------
  12 +Implement signals in plugins is optional! You may follow this steps only if you
  13 +want to communicate with another plugins.
12 14
13 In order to configure a plugin to able to listen and send signals using Colab 15 In order to configure a plugin to able to listen and send signals using Colab
14 signals structure, some steps are required: 16 signals structure, some steps are required:
@@ -42,15 +44,17 @@ signals structure, some steps are required: @@ -42,15 +44,17 @@ signals structure, some steps are required:
42 44
43 * With signals registered and handling method defined you must connect them. 45 * With signals registered and handling method defined you must connect them.
44 To do it you must call connect_signal passing signal name, sender and handling 46 To do it you must call connect_signal passing signal name, sender and handling
45 - method as arguments. This calling must be into ready function in apps.py. 47 + method as arguments. These should be implemented on plugin's apps.py. It must
  48 + be said that the plugin app class must extend ColabProxiedAppConfig. An
  49 + example of this configuration can be seen below:
46 50
47 51
48 .. code-block:: python 52 .. code-block:: python
49 - from colab.plugins.utils.signals import AbstractSignal 53 + from colab.plugins.utils.apps import ColabProxiedAppConfig
50 from colab.signals.signals import register_signal, connect_signal 54 from colab.signals.signals import register_signal, connect_signal
51 from colab.plugins.PLUGIN.tasks import HANDLING_METHOD 55 from colab.plugins.PLUGIN.tasks import HANDLING_METHOD
52 56
53 - class PluginSignals(AbstractSignal): 57 + class PluginApps(ColabProxiedAppConfig):
54 short_name = PLUGIN_NAME 58 short_name = PLUGIN_NAME
55 signals_list = [SIGNAL1, SIGNAL2] 59 signals_list = [SIGNAL1, SIGNAL2]
56 60
@@ -69,6 +73,8 @@ signals structure, some steps are required: @@ -69,6 +73,8 @@ signals structure, some steps are required:
69 \*\*kwargs. As you can see below: 73 \*\*kwargs. As you can see below:
70 74
71 .. code-block:: python 75 .. code-block:: python
  76 + from colab.signals.signals import send
  77 +
72 send(signal_name, sender) 78 send(signal_name, sender)
73 79
74 * If you want to run celery manually to make some tests, you should execute: 80 * If you want to run celery manually to make some tests, you should execute: