主题
Observable
Mixin: notifies when fields change; auto-wraps lists/dicts to be observable.
Example: ```python import flet as ft from dataclasses import dataclass
@ft.observable
@dataclass
class MyDataClass:
x: int
y: int
obj = MyDataClass(1, 2)
def listener(sender, field):
print(f"Changed: {field} in {sender}")
obj.subscribe(listener)
obj.x = 3
obj.y = 4
```
方法
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
subscribe | Callable[[], None] | — | Register a change listener. Args: fn: Listener callback receiving (sender, field). Returns: A disposer function that unsubscribes the listener. |
notify | — | — | Manually notify listeners that something changed. |