From 3ba56a809679fb0b50b0cdb0192a5246ed16e6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 28 Jun 2018 17:31:55 +0200 Subject: [PATCH] Implement batch callback subscription in CallbackMixin --- lib/tfw/mixins/callback_mixin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tfw/mixins/callback_mixin.py b/lib/tfw/mixins/callback_mixin.py index 3c94e71..54515f3 100644 --- a/lib/tfw/mixins/callback_mixin.py +++ b/lib/tfw/mixins/callback_mixin.py @@ -21,6 +21,14 @@ class CallbackMixin: fun = partial(callback, *args, **kwargs) 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): self._callbacks.remove(callback)