Basic Signal
A signal is a reactive state cell. Create one by passing the initial value to
signal(). From there, .get() reads the current value and .set(v) replaces it.
Signals accept any type: integers, strings, maps, arrays, structs.
Creating, reading and writing signals with distinct values.
01-signal-basics.zolo
// Feature: signals — fine-grained reactive state
// Syntax: `signal(initial)` creates a cell; `s.get()` reads,
// `s.set(v)` writes. Reads inside `effect` / `computed`
// register a dependency.
// When to use: UI state, derived values, cache invalidation —
// anywhere "X depends on Y" should re-run when Y changes.
use std::Signal
let s = signal(42)
print(s.get())
// expected: 42
s.set(100)
print(s.get())
// expected: 100
// Signals carry any value: ints, strings, maps, arrays, structs.
let name = signal("zolo")
name.set("lang")
print(name.get())
// expected: lang
Challenge
Create a list signal, add elements with .modify(|v| { ... }) and
print the size after each modification.
See also