SingleCallback

Defined in module: wield.declarative.callbacks.callbacks.SingleCallback

class SingleCallback(default=None, doc=None)[source][github]

Bases: object

Provides 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.

__init__(default=None, doc=None)[source][github]

Methods

__init__([default, doc])

register(callback[, remove])

Register the function into the callback

Attributes

default[github]
callback[github]
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.