Signal
- class jwst.lib.signal_slot.Signal(*funcs)[source]
Bases:
objectA Signal, when triggered, call the connected slots.
- Parameters:
- *funcsfunc[, …]
Remaining arguments will be functions to connect to this signal.
- Attributes:
enabledboolWhether signal is active or not.
Attributes Summary
Whether signal is active or not.
Generator returning slots.
Methods Summary
__call__(*args, **kwargs)Invoke slots attached to the signal.
call(*args, **kwargs)Return result of each slot connected as a generator.
clear([single_shot])Clear slots.
connect(func[, single_shot])Connect a function to the signal.
disconnect(func)Disconnect the signal.
emit(*args, **kwargs)Invoke slots attached to the signal.
reduce(*args, **kwargs)Return a reduction of all the slots.
Reset activation state of signal.
set_enabled(state[, push])Set whether signal is active or not.
Attributes Documentation
- enabled
Whether signal is active or not.
- slots
Generator returning slots.
Methods Documentation
- __call__(*args, **kwargs)
Invoke slots attached to the signal.
No return of results is expected.
- Parameters:
- *argstuple
Positional arguments to pass to the slots.
- **kwargsdict
Keyword arguments to pass to the slots.
- call(*args, **kwargs)[source]
Return result of each slot connected as a generator.
- Parameters:
- *argstuple
Positional arguments to pass to the slots.
- **kwargsdict
Keyword arguments to pass to the slots.
- Returns:
- generator
A generator returning the result from each slot.
- clear(single_shot=False)[source]
Clear slots.
- Parameters:
- single_shotbool
If True, only remove single shot slots.
- connect(func, single_shot=False)[source]
Connect a function to the signal.
- Parameters:
- funcfunction or method
The function/method to call when the signal is activated.
- single_shotbool
If True, the function/method is removed after being called.
- emit(*args, **kwargs)[source]
Invoke slots attached to the signal.
No return of results is expected.
- Parameters:
- *argstuple
Positional arguments to pass to the slots.
- **kwargsdict
Keyword arguments to pass to the slots.
- reduce(*args, **kwargs)[source]
Return a reduction of all the slots.
- Parameters:
- *argstuple
Positional arguments to pass to the slots.
- **kwargsdict
Keyword arguments to pass to the slots.
- Returns:
- resultobject or (object [,…])
The result or tuple of results. See Notes.
Notes
Each slot is given the results of the previous slot as a new positional argument list. As such, if multiple arguments are required, each slot should return a tuple that can then be passed as arguments to the next function.
The keyword arguments are simply passed to each slot unchanged.
There is no guarantee on order which the slots are invoked.