unsafe__withoutCapture

See source code

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.

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

NameDescription

fn

() => T

Returns

T
Prev
transaction
Next
whyAmIRunning

We use cookies on this website.
Learn more in our Cookie Policy.