Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/tiny-engine/llms.txt
Use this file to discover all available pages before exploring further.
useComputed derives a read-only signal from one or more existing signals. The supplied function is executed immediately to compute the initial value, and then re-executed automatically whenever any signal that was read during the previous computation changes. The result is exposed as a getter just like the one returned by useSignal.
Signature
Parameters
The computation function. Any
SignalGetter called inside this function is tracked as a dependency. When a dependency changes the function is re-run and the derived value is updated.When
true, the computed value is also re-evaluated when the component’s root node fires its started event. Defaults to false. Use this when the computation depends on a value — such as a script reference — that is only available after the node finishes initialising.Return value
SignalGetter<T> — a zero-argument function () => T. Reading it inside JSX props or other reactive contexts automatically tracks it as a dependency.
Examples
Cooldown progress bar
CooldownBar.tsx
Reactive animation name
PlayerSprite.tsx
Depending on a script reference (refreshOnNodeStart)
When the computation relies on a value that only exists after the node starts — such as aTinyScript property — pass true as the second argument:
BossHealthBar.tsx
useComputed returns a read-only getter. There is no setter — attempting to update the underlying signal directly is not possible. If you need writable derived state, use useSignal and update it inside a useEffect.