cleanup and update phases are intermingled
pygy opened this issue · 2 comments
Hi Adam, I know the project isn't active, but I'm tinkering with it while implementing a variation on the same idea and I think I found a bug in S
. I'll leave it here if only for documentation:
const {data, freeze, cleanup, root} = S
root(()=>{
const s1 = data(1)
const s2 = data(2)
const a = S(()=> {
return "a:"+s1()
})
const b = S(()=> {
console.log("b running", a())
cleanup(()=>console.log("b cleanup", a()))
})
s1(10)
})
Expected:
b running a:1
b cleanup a:1
b running a:10
Actual output:
b running a:1
b cleanup a:10
b running a:10
Edit: This used to mention freeze and nested computations for accidental reasons, I had failed to reduce the test case. It looks like the behavior is by design, but I find it surprising, given the emphasis on atomic instants.
@pygy could you link to your project?
I am very interested in it but could not find it among your public repos on GitHub.
You can find the preliminary version here.
The API apes the blurry memory I had of S, but some bits differ, it may or may not converge to full B/W compat.
Some bits are entirely untested (even manually), this is very preliminary stuff. The lib is UI-oriented, and thus doesn't support reactivity when using circular references. In other words, you can't implement reactive loops like you can in S.
No idea about the performance either.