From c06c90f4fd5aaeea45b24192fbfb9ee451a17cc2 Mon Sep 17 00:00:00 2001 From: Xavier Cho Date: Tue, 25 Aug 2020 06:16:56 +0900 Subject: [PATCH] Make `read_only` property, well, read-only --- alleycat/reactive/value.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/alleycat/reactive/value.py b/alleycat/reactive/value.py index 80a9c8e..3f5b608 100644 --- a/alleycat/reactive/value.py +++ b/alleycat/reactive/value.py @@ -32,7 +32,7 @@ class ReactiveValue(Generic[T], ABC): def __init__(self, read_only=False) -> None: self._name: Optional[str] = None - self.read_only = read_only + self._read_only = read_only data: RequiresContext[Any, ReactiveValue.Data[T]] = RequiresContext(lambda obj: self._get_data(obj)) @@ -44,6 +44,10 @@ def __init__(self, read_only=False) -> None: def name(self) -> Optional[str]: return self._name + @property + def read_only(self) -> bool: + return self._read_only + def observable(self, obj: Any) -> Observable: if obj is None: raise ValueError("Cannot observe a None object.")