Skip to content

REPL

import { atom, createCtx } from '@reatom/core'

const ctx = createCtx()

const numberAtom = atom(0, 'numberAtom')
const doubleAtom = atom((ctx) => {
console.log(ctx.cause)
return ctx.spy(numberAtom) * 2
}, 'doubleAtom')

ctx.subscribe(doubleAtom, console.log)
numberAtom(ctx, (s) => s + 1)