Signal
Signals are a simple pub-sub mechanism.
DOMNodes can subscribe to a signal, which will invoke a callback when the signal is published.
This is experimental for now, for internal use. It may be part of the public API in a future release.
Signal
class
¶
Bases: Generic[SignalT]
A signal that a widget may subscribe to, in order to invoke callbacks when an associated event occurs.
Parameters
Parameter | Default | Description |
---|---|---|
owner
MessagePump
|
required | The owner of this signal. |
name
str
|
required | An identifier for debugging purposes. |
publish
method
¶
Publish the signal (invoke subscribed callbacks).
Parameters
Parameter | Default | Description |
---|---|---|
data
SignalT
|
required | An argument to pass to the callbacks. |
subscribe
method
¶
Subscribe a node to this signal.
When the signal is published, the callback will be invoked.
Parameters
Parameter | Default | Description |
---|---|---|
node
MessagePump
|
required | Node to subscribe. |
callback
SignalCallbackType
|
required | A callback function which takes a single argument and returns anything (return type ignored). |
Raises
Type | Description |
---|---|
SignalError
|
Raised when subscribing a non-mounted widget. |
unsubscribe
method
¶
Unsubscribe a node from this signal.
Parameters
Parameter | Default | Description |
---|---|---|
node
MessagePump
|
required | Node to unsubscribe, |