Implement batch callback subscription in CallbackMixin

This commit is contained in:
Kristóf Tóth 2018-06-28 17:31:55 +02:00
parent 9eacf3f79c
commit 3ba56a8096

View File

@ -21,6 +21,14 @@ class CallbackMixin:
fun = partial(callback, *args, **kwargs) fun = partial(callback, *args, **kwargs)
self._callbacks.append(fun) self._callbacks.append(fun)
def subscribe_callbacks(self, *callbacks):
"""
Subscribe a list of callbacks to incoke once an event is triggered.
:param callbacks: callbacks to be subscribed
"""
for callback in callbacks:
self.subscribe_callback(callback)
def unsubscribe_callback(self, callback): def unsubscribe_callback(self, callback):
self._callbacks.remove(callback) self._callbacks.remove(callback)