Thunderous
Quick Start
Overview
Defining Custom Elements
Rendering
Lifecycle Methods
Root and Element Internals
Adopted Style Sheets
Event Binding
Refs
Registries
SSR
Types
Signals
Signals Overview
Binding Signals
Attribute Signals
Property Signals
Derived Signals
Effects
Debugging Signals
Releases
2.0.0
1.0.0
View All Releases
(invalid icon)
Derived Signals
If you want to calculate a value based on another signal's value, you should use the
derived()
function. This signal will trigger its subscribers each time the signals inside change.
import
{ derived, createSignal }
from
'thunderous'
;
const
[count, setCount] =
createSignal
(
0
);
const
timesTen =
derived
(
() =>
count
() *
10
);
console
.
log
(
timesTen
());
// 0
setCount
(
10
);
console
.
log
(
timesTen
());
// 100