See #11 for context...
These are notes (mostly to myself) on how to best implement the proposed additions in the issue linked above:
- A global
Dispatcher instance should be made available at the package level.
- All necessary
Dispatcher methods of the global instance should be added as functions at the package level mapping to the instance.
- Thread safety needs to be addressed and thought through.
- To avoid conflict with a single instance holding all events:
- should event names may need to be name-spaced?
- should an exception be raised in
register_event if an event already exists with that name?
- Binding to an event that hasn't been registered yet would be nice. Would require caching the callback and event name (shouldn't be too difficult).
- Event emission can be done using the global
Dispatcher.emit(<name>, ...) method, but exposing the Event instances themselves should be available:
import pydispatch
# Dispatcher.emit() method
pydispatch.register_event('signal_a')
pydispatch.emit('signal_a')
# Event object method
signal_b = pydispatch.register_event('signal_b')
signal_b.emit()
See #11 for context...
These are notes (mostly to myself) on how to best implement the proposed additions in the issue linked above:
Dispatcherinstance should be made available at the package level.Dispatchermethods of the global instance should be added as functions at the package level mapping to the instance.register_eventif an event already exists with that name?Dispatcher.emit(<name>, ...)method, but exposing theEventinstances themselves should be available: