You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Signals are the source of truth in the system. They hold raw values that can change over time.
41
+
Updating a signal automatically marks any dependent computations as potentially stale.
42
+
43
+
2.**Memo**
44
+
Memos are derived, computed values that depend on one or more signals (or other memos).
45
+
When a signal changes, all memos that depend on it are invalidated.
46
+
Accessing a memo after invalidation triggers lazy recomputation, ensuring that cached values are always consistent.
47
+
48
+
3.**Effect**
49
+
Effects are side-effectful computations that run automatically whenever their dependencies change.
50
+
They subscribe to signals and memos, reacting to updates without manual intervention.
51
+
Effects do not produce cached values; instead, they propagate changes outward (e.g., updating UI, logging, or triggering external events).
52
+
53
+
**Dependency Flow:**
54
+
55
+
-**Signals** update their dependents (memos/effects).
56
+
-**Memos** recompute lazily when accessed, maintaining up-to-date derived values.
57
+
-**Effects** automatically react whenever any dependency they use changes.
58
+
59
+
This separation ensures efficient and predictable propagation: cached computations are only recomputed when needed, while side effects happen immediately when dependencies change.
60
+
61
+
This three-level model ensures that changes propagate efficiently, only recomputing what is necessary, and automatically triggering side-effects in a controlled and predictable way.
0 commit comments