Signals hold mutable state
A signal is a piece of reactive state that tracks its dependants and notifies them when its value changes. In Rust, Signal<T> is a handle to that state. Copying the handle shares that value. Reading a signal inside a reactive computation records a dependency; updating it schedules the affected readers.
<script>let count: Signal<i32> = Signal::new(0);let increment = move || count.update(|n| *n += 1);</script><style>:global(body) { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }button { padding: 8px 12px; }</style><button onclick={increment}>Clicked {count} times</button> The declaration needs its explicit Signal<i32> type. The counter’s closure calls update to change the stored number in place. In a text hole, the compiler turns a bare signal name into a read. Attribute expressions and template conditions use explicit reads such as count.get().
Memos derive values
Use a memo when a value is computed from other state. A memo is lazy: its closure runs when it is first read, then when a changed dependency requires recomputation. Readers are notified when the derived value changes according to PartialEq.
<script>let count: Signal<i32> = Signal::new(0);let doubled: Memo<i32> = Memo::new(move || count.get() * 2);let increment = move || count.update(|n| *n += 1);</script><style>:global(body) { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }button { padding: 8px 12px; }</style><button onclick={increment}>Count: {count}</button><p>Double: {doubled}</p> Here doubled depends on count. It is not a second counter that must be updated alongside the first one. The event handler changes only count.
Effects run after writes
The runtime is single-threaded. Effects run synchronously after a signal write, or after the outermost batch, in creation order. A diamond-shaped dependency graph is evaluated once for the update rather than once per path.
Batch related writes when their readers should see the resulting state together. Do not depend on an effect reading an intermediate value inside an unfinished outer batch.
Owners define lifetimes
Components, conditional branches and list rows own their reactive work. When one is removed, its owner is disposed and its effects stop. A signal handle does not make an already disposed owner live again.
Fallible reads such as try_get return an error for a disposed signal. Convenience methods such as get panic with the same diagnostic. A memo cycle is refused with the node’s name. Choose the fallible operations when the caller needs to handle failure explicitly.
Values passed to children
A normal prop is read at mount. Passing a parent’s current value does not automatically resend future values. A prop typed as Signal<T> shares the state handle and can be read reactively by the child. See Child components before choosing a prop type.