mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 16:41:32 +00:00
Use power of LazyInitialise to replace CallbackMixin.__init__()
This commit is contained in:
parent
cebacb15e6
commit
6f3db18146
@ -36,7 +36,6 @@ class HistoryMonitor(CallbackMixin, ObserverMixin, ABC):
|
|||||||
See examples below.
|
See examples below.
|
||||||
"""
|
"""
|
||||||
def __init__(self, histfile):
|
def __init__(self, histfile):
|
||||||
CallbackMixin.__init__(self)
|
|
||||||
self.histfile = histfile
|
self.histfile = histfile
|
||||||
self._history = []
|
self._history = []
|
||||||
self._last_length = len(self._history)
|
self._last_length = len(self._history)
|
||||||
|
@ -19,7 +19,6 @@ class FSMBase(CallbackMixin):
|
|||||||
states, transitions = [], []
|
states, transitions = [], []
|
||||||
|
|
||||||
def __init__(self, initial: str = None, accepted_states: List[str] = None):
|
def __init__(self, initial: str = None, accepted_states: List[str] = None):
|
||||||
CallbackMixin.__init__(self)
|
|
||||||
self.accepted_states = accepted_states or [self.states[-1]]
|
self.accepted_states = accepted_states or [self.states[-1]]
|
||||||
self.machine = Machine(model=self,
|
self.machine = Machine(model=self,
|
||||||
states=self.states,
|
states=self.states,
|
||||||
|
@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
from tfw.decorators import LazyInitialise
|
||||||
|
|
||||||
|
|
||||||
class CallbackMixin:
|
class CallbackMixin:
|
||||||
def __init__(self):
|
@LazyInitialise
|
||||||
self._callbacks = []
|
def _callbacks(self):
|
||||||
|
return []
|
||||||
|
|
||||||
def subscribe_callback(self, callback, *args, **kwargs):
|
def subscribe_callback(self, callback, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user