Skip to content

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

def __init__(self, owner, name):

A signal that a widget may subscribe to, in order to invoke callbacks when an associated event occurs.

Parameters
Parameter Default Description
owner
DOMNode
required

The owner of this signal.

name
str
required

An identifier for debugging purposes.

publish method

def publish(self):

Publish the signal (invoke subscribed callbacks).

subscribe method

def subscribe(self, node, callback):

Subscribe a node to this signal.

When the signal is published, the callback will be invoked.

Parameters
Parameter Default Description
node
DOMNode
required

Node to subscribe.

callback
IgnoreReturnCallbackType
required

A callback function which takes no arguments, and returns anything (return type ignored).

Raises
Type Description
SignalError

Raised when subscribing a non-mounted widget.

unsubscribe method

def unsubscribe(self, node):

Unsubscribe a node from this signal.

Parameters
Parameter Default Description
node
DOMNode
required

Node to unsubscribe,

SignalError class

Bases: Exception

Raised for Signal errors.