unsafe__withoutCapture
See source codeExecutes the given function without capturing any parents in the current capture context.
This is mainly useful if you want to run an effect only when certain signals change while also dereferencing other signals which should not cause the effect to rerun on their own.
function unsafe__withoutCapture<T>(fn: () => T): T
Example
const name = atom('name', 'Sam')
const time = atom('time', () => new Date().getTime())
setInterval(() => {
time.set(new Date().getTime())
})
react('log name changes', () => {
print(
name.get(),
'was changed at',
unsafe__withoutCapture(() => time.get())
)
})
Parameters
Name | Description |
---|---|
|
|
Returns
T
Prev
transactionNext
whyAmIRunning