unsafe__withoutCapture()
Executes 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.
Example
const name = atom('name', 'Sam')
const time = atom('time', () => new Date().getTime())
setInterval(() => {
time.set(new Date().getTime())
})
react('log name changes', () => {
console.log(name.value, 'was changed at', unsafe__withoutCapture(() => time.value))
})
Signature
unsafe__withoutCapture<T>(fn: Function): T;
Type parameters
T
Parameters
Name | Type |
---|---|
fn | () => T |
Returns
T
Defined in: signia/src/capture.ts:38