mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 16:41:21 +00:00
Implement batch callback subscription in CallbackMixin
This commit is contained in:
parent
9eacf3f79c
commit
3ba56a8096
@ -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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user