Adds support for recursion. 🥳
Recursion is supported with set.recurse for both sync and async use cases, but is not supported in the cleanup function.
const countAtom = atom(0)
atomEffect((get, set) => {
// increments count once per second
const count = get(countAtom)
const timeoutId = setTimeout(() => {
set.recurse(countAtom, increment)
}, 1000)
return () => clearTimeout(timeoutId)
})What's Changed
- Recurse by @dmaskasky in #29
Full Changelog: v0.3.2...v0.4.0