What is this?
signaling is a simple implementation of the signal/slot pattern as known from the Qt framework. It has no external requirements and 100% test-coverage.
Installation
The usual
pip install signaling
How to use it?
Consider that you have a function that should be called whenever a connected signal is emitted, as illustrated by the following code block:
def slot(arg):
print("Slot called with {}".format(arg))
signal = Signal(args=['arg'])
signal.connect(slot)
signal.emit(arg=1) # Slot called with 1
In fact you can connect multiple slots to the same signal, as long as they share the same function signature.
Notice that the signaling library performs some sanity checks when connecting slots and emitting signals.
All slots connected to a signal have to provide the same argument specifiction as denoted by the args parameter of the Signal constructor.
An emit-call has to be made with the exact same arguments as specified with the Signal constructor.
So all of the below examples would raise an exception:
def slot_with_arg(arg):
pass
def slot_without_arg():
pass
# InvalidSlot: Slot 'slot_with_arg' has to callable without arguments
Signal().connect(slot_with_arg)
# InvalidSlot: Slot 'slot_without_args' has to accept args ['arg'] or **kwargs.
Signal(args['arg']).connect(slot_without_arg)
s = Signal()
s.connect(slot_without_args)
# InvalidEmit: Emit has to be called without arguments.
s.emit(foo=1)
Metadata
Release files for signaling 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| signaling-1.0.0.tar.gz | 11.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| signaling-1.0.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 17.6 kB
Release files / signaling-1.0.0.tar.gz
| Download URL | signaling-1.0.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0051e5ec8fc4bba7eaf41ea035143229e62a132f1be3eb4354340707d34dff25
|
|
BLAKE2b-256 checksum How to use checksums |
871e8761e25fdc6183c92fc9ddd5d4ce1e86eda8ba61bf4ceacd957709818a19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / signaling-1.0.0-py2.py3-none-any.whl
| Download URL | signaling-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2f1dc686c25254238171d76effa6bd0386a54c38d63086d748fd8f5c7633d93d
|
|
BLAKE2b-256 checksum How to use checksums |
cebb4e794667198ec5aee704695538ffee9bcfc463e6c678be4139905cd44966
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |