1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//! Reactive state management system.
//!
//! Vue/SolidJS-inspired reactivity with automatic dependency tracking.
//! Create reactive state with [`signal()`], derived values with [`computed()`],
//! and side effects with [`effect()`].
//!
//! # Core Primitives
//!
//! | Primitive | Description | Use Case |
//! |-----------|-------------|----------|
//! | [`Signal`] | Reactive value | Mutable state |
//! | [`Computed`] | Derived value | Automatic recalculation |
//! | [`Effect`] | Side effect | React to changes |
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use revue::prelude::*;
//!
//! // Create reactive state
//! let count = signal(0);
//!
//! // Derived value (auto-updates when count changes)
//! let doubled = computed(move || count.get() * 2);
//!
//! // Side effect (runs when dependencies change)
//! effect(move || {
//! println!("Count is now: {}", count.get());
//! });
//!
//! count.set(5);
//! // Output: "Count is now: 5"
//! // doubled.get() returns 10
//! ```
//!
//! # Signal
//!
//! A [`Signal`] holds a reactive value that can be read and written:
//!
//! ```rust,ignore
//! let name = signal(String::from("World"));
//!
//! // Read the value
//! println!("Hello, {}!", name.get());
//!
//! // Update the value
//! name.set(String::from("Revue"));
//!
//! // Update based on current value
//! name.update(|n| n.push_str("!"));
//! ```
//!
//! # Computed
//!
//! A [`Computed`] value automatically recalculates when its dependencies change:
//!
//! ```rust,ignore
//! let items = signal(vec![1, 2, 3, 4, 5]);
//!
//! let sum = computed(move || items.get().iter().sum::<i32>());
//! let avg = computed(move || {
//! let v = items.get();
//! v.iter().sum::<i32>() as f64 / v.len() as f64
//! });
//!
//! println!("Sum: {}, Avg: {}", sum.get(), avg.get()); // 15, 3.0
//!
//! items.update(|v| v.push(10));
//! println!("Sum: {}, Avg: {}", sum.get(), avg.get()); // 25, ~4.17
//! ```
//!
//! # Effect
//!
//! An [`Effect`] runs a callback whenever its dependencies change:
//!
//! ```rust,ignore
//! let theme = signal("dark");
//!
//! effect(move || {
//! let current = theme.get();
//! apply_theme(current);
//! });
//!
//! theme.set("light"); // apply_theme("light") is called
//! ```
//!
//! # Best Practices
//!
//! 1. **Keep signals granular**: Prefer multiple small signals over one large object
//! 2. **Use computed for derived state**: Don't duplicate state that can be calculated
//! 3. **Avoid side effects in computed**: Use `effect` for side effects
//! 4. **Clone signals freely**: Signals are cheap to clone (reference-counted)
pub use ;
pub use ;
pub use Computed;
pub use ;
pub use Effect;
pub use ;
pub use ReactiveRuntime;
pub use ;
pub use ;
pub use ;
pub use ;
use ;
/// Unique identifier for signals
;
/// Create a new reactive signal
/// Create a computed value
///
/// The closure must be `Send + Sync` since Signals are thread-safe.
/// Create a side effect
///
/// The closure must be `Send + Sync` since Signals are thread-safe.
/// This is automatically satisfied when capturing Signals.
/// Create a reactive vector with fine-grained change tracking
///
/// Unlike `signal(Vec<T>)`, this tracks individual insert/remove/update
/// operations for efficient incremental updates.
///
/// # Example
///
/// ```rust,ignore
/// let items = signal_vec(vec![1, 2, 3]);
///
/// // Each operation emits a granular change
/// items.push(4); // VecDiff::Insert { index: 3, value: 4 }
/// items.remove(1); // VecDiff::Remove { index: 1, value: 2 }
/// items.update(0, 10); // VecDiff::Update { index: 0, old: 1, new: 10 }
/// ```