import * as Atom from '@effect-atom/atom/Atom'
import { useAtom, useAtomValue } from '@effectify/solid-effect-atom'
const countAtom = Atom.make(0)
const doubledAtom = Atom.make((get) => get(countAtom) * 2)
function Counter() {
const [count, setCount] = useAtom(() => countAtom)
const doubled = useAtomValue(() => doubledAtom)
return (
<div>
<p>Count: {count()}</p>
<p>Doubled: {doubled()}</p>
<button onClick={() => setCount(count() - 1)}>β</button>
<button onClick={() => setCount(0)}>Reset</button>
<button onClick={() => setCount(count() + 1)}>+</button>
</div>
)
}
import * as Atom from '@effect-atom/atom/Atom'
import { useAtom, useAtomValue } from '@effectify/solid-effect-atom'
const countAtom = Atom.make(0)
const doubledAtom = Atom.make((get) => get(countAtom) * 2)
function Counter() {
const [count, setCount] = useAtom(() => countAtom)
const doubled = useAtomValue(() => doubledAtom)
return (
<div>
<p>Count: {count()}</p>
<p>Doubled: {doubled()}</p>
<button onClick={() => setCount(count() - 1)}>β</button>
<button onClick={() => setCount(0)}>Reset</button>
<button onClick={() => setCount(count() + 1)}>+</button>
</div>
)
}