Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup and update phases are intermingled #56

Open
pygy opened this issue Jan 4, 2023 · 2 comments
Open

cleanup and update phases are intermingled #56

pygy opened this issue Jan 4, 2023 · 2 comments

Comments

@pygy
Copy link

pygy commented Jan 4, 2023

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.

Here's the test case live

@dumblob
Copy link

dumblob commented Jan 4, 2023

@pygy could you link to your project?

I am very interested in it but could not find it among your public repos on GitHub.

@pygy
Copy link
Author

pygy commented Jan 4, 2023

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.

@pygy pygy changed the title When using freeze, cleanup and update phases are intermingled cleanup and update phases are intermingled Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants