JAForbes / S

MIT License
6 stars 0 forks source link

Investigate behaviour of parent computation lifecycle vs root dispose #21

Open JAForbes opened 1 year ago

JAForbes commented 1 year ago

If you dispose a root, it won't dispose children in a nested root. This rewrite already has this behaviour.

But when a parent computation re-runs any nested computations are destroyed as the parent computation will recreate them.

In this case, what is meant to happen when the parent computation initiates a child root. Does the old child root automatically clean up, or is it meant to be protected?

S.computation(() => { // when this re-runs

  S.root(() => {
    S.computation(() => { // does this get destroyed?

    })
  })
})

I think it should be destroyed/recreated because that is how S works at the most basic level, but it seems to make root's less independent than you'd expect.