SingleCallback¶
Defined in module: wield.declarative.callbacks.callbacks.SingleCallback
- class SingleCallback(default=None, doc=None)[source][github]¶
Bases:
objectProvides a callback which can only be registered to once, allowing the callback to provide a return value. This type uses the __call__ interface to transparently act as the callback registered to it.
- Parameters:
default – a default function to call if the callback is not registered.
The default argument also provides the docstring for the descriptor attribute.
- register(callback, remove=False)[source][github]¶
Register the function into the callback
- Parameters:
key (hashable) – registration key for callback
callback – function to be called
- Raises:
KeyError if callback key is already present or if removing and not present.
Methods
Attributes