| | 150 | There is a built-in signaling system, represented by the Signal class in the core.signal shared module. It is is a classic signaling implementation: signals can be declared, connected to and arguments can be passed when the signal is triggered. |
| | 151 | |
| | 152 | Example: |
| | 153 | {{{ |
| | 154 | #!python |
| | 155 | |
| | 156 | from core.signal import Signal |
| | 157 | |
| | 158 | # declare the signal |
| | 159 | spamArrived = Signal() |
| | 160 | |
| | 161 | # create signal handler |
| | 162 | def handleSpam(spamType): |
| | 163 | print("delicious %d arrived!" % spamType) |
| | 164 | |
| | 165 | # connect handler to the signal |
| | 166 | spamArrived.connect(handleSpam) |
| | 167 | |
| | 168 | # trigger the signal & pass an argument |
| | 169 | spamArrived("original SPAM") |
| | 170 | }}} |
| | 171 | |