queryDb()— reactive SQL queries backed by SQLitesignal()— reactive in-memory values (not persisted)computed()— derived values that recalculate when their dependencies change
$ by convention (e.g. todos$, count$).
signal
Creates a reactive in-memory value. Signals are useful for ephemeral UI state — such as search text, selected item IDs, or filter settings — that needs to trigger query re-evaluation but should not be stored in the database or synced to other clients.
Parameters
The initial value of the signal. Can be any type: primitives, objects, arrays, or functions.
Human-readable name shown in the DevTools for this signal. Recommended for all signals to ease debugging.
Return type
signal() returns a SignalDef<T> — a reusable definition, not an active instance. The signal is instantiated the first time it is used with a store.
Reading a signal
Usestore.query(signal$) for a synchronous one-shot read, or pass the signal to store.subscribe() / store.useQuery() for reactive subscriptions.
Setting a signal
Usestore.setSignal(signal$, newValue) to update the signal’s value. Accepts either a new value or an updater function that receives the previous value.
Complete signal example
computed
Creates a derived reactive value from other queries, signals, or computed values. The computation re-runs only when its dependencies change. If the new result is equal to the previous one, downstream subscribers are not notified.
Parameters
Pure function that computes the result. Call
get(query$) inside the function to read other reactive values and register them as dependencies. When any dependency changes, fn re-evaluates.Human-readable name shown in the DevTools.
Explicit dependency key. Required on Expo / React Native where
fn.toString() returns [native code].Return type
computed() returns a LiveQueryDef<TResult>. Use it with store.query(), store.subscribe(), or store.useQuery() just like a queryDb definition.
Examples
Using reactive state with the store
All three reactive types (queryDb, signal, computed) are accessed the same way:
Reactive queries that depend on signals
Combinesignal and queryDb to build queries that react to both database changes and local UI state.
Naming convention
By convention, reactive state variable names end with a$ suffix. This makes it easy to distinguish definitions from plain values:
When to use signals vs queryDb
queryDb | signal | |
|---|---|---|
| Persisted | Yes (via events) | No |
| Synced | Yes | No |
| Source of truth | SQLite tables | In-memory only |
| Lifetime | Store lifetime | Store lifetime |
| Typical use | Application data | UI state, filters, selections |
queryDb for any data that should survive a page reload or be visible to other clients. Use signal for transient UI state — selected items, open panels, search text — that should reset when the store restarts.
Signals are lost on page reload. If you need persistent local-only state, define a
State.SQLite.clientDocument table and commit Events.clientOnly events instead.