The compute callback will be executed (and re-executed as necessary) to provide the current value.
The function body of compute is tracked automatically: any reactive values used by compute
will be watched automatically; if any of them changes then the computed value will be updated as well.
NOTE: the compute callback should not have any side effects as it may be called any number of times
if its dependencies change.
Creates a new computed signal.
The
compute
callback will be executed (and re-executed as necessary) to provide the current value. The function body ofcompute
is tracked automatically: any reactive values used bycompute
will be watched automatically; if any of them changes then the computed value will be updated as well.Example: