Attributes with superpowers
Project description
reacttrs
Reactive attributes extracted out from Textual.
from reacttrs import reactive
class Foo:
name = reactive("Paul")
age = reactive(33)
birth = reactive(1990)
def watch_name(self, old, new):
print(f"{old=}, {new=}")
def validate_name(self, name):
if name == "John":
print("Hey John!")
return name
def compute_age(self) -> int:
age = 2023 - self.birth
print(f"{age=}")
return age
foo = Foo()
foo.name = "John"
foo.name = "Steve"
foo.age
foo.birth = 1991
foo.age
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reacttrs-0.1.4.tar.gz
(4.2 kB
view hashes)