diff --git a/src/cpl_reactive_extensions/behavior_subject.py b/src/cpl_reactive_extensions/behavior_subject.py index 18b087c0..67121644 100644 --- a/src/cpl_reactive_extensions/behavior_subject.py +++ b/src/cpl_reactive_extensions/behavior_subject.py @@ -1,10 +1,10 @@ from cpl_core.type import T -from cpl_reactive_extensions.observable import Observable +from cpl_reactive_extensions.subject import Subject -class BehaviorSubject(Observable): +class BehaviorSubject(Subject): def __init__(self, _t: type, value: T): - Observable.__init__(self, lambda x: x) + Subject.__init__(self, _t) if not isinstance(value, _t): raise TypeError(f"Expected {_t.__name__} not {type(value).__name__}") @@ -17,7 +17,6 @@ class BehaviorSubject(Observable): return self._value def next(self, value: T): - if not isinstance(value, self._t): - raise TypeError(f"Expected {self._t.__name__} not {type(value).__name__}") + super().next(value) self._value = value diff --git a/src/cpl_reactive_extensions/subject.py b/src/cpl_reactive_extensions/subject.py index 0ae3f134..2b2c40fc 100644 --- a/src/cpl_reactive_extensions/subject.py +++ b/src/cpl_reactive_extensions/subject.py @@ -34,7 +34,7 @@ class Subject(Observable, Observer): self._raise_if_closed() if not isinstance(value, self._t): - raise TypeError() + raise TypeError(f"Expected {self._t.__name__} not {type(value).__name__}") if self.is_stopped: return