mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-09 17:47:16 +00:00
21 lines
583 B
Python
21 lines
583 B
Python
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
# All Rights Reserved. See LICENSE file for details.
|
|
|
|
from functools import partial
|
|
|
|
|
|
class CallbackMixin:
|
|
def __init__(self):
|
|
self._callbacks = []
|
|
|
|
def subscribe_callback(self, callback, *args, **kwargs):
|
|
fun = partial(callback, *args, **kwargs)
|
|
self._callbacks.append(fun)
|
|
|
|
def unsubscribe_callback(self, callback):
|
|
self._callbacks.remove(callback)
|
|
|
|
def _execute_callbacks(self, *args, **kwargs):
|
|
for callback in self._callbacks:
|
|
callback(*args, **kwargs)
|