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

Watchers have inconsistent state inside watched callback #208

Open
prophile opened this issue Apr 29, 2024 · 1 comment
Open

Watchers have inconsistent state inside watched callback #208

prophile opened this issue Apr 29, 2024 · 1 comment

Comments

@prophile
Copy link
Contributor

Consider the following code:

let watcher
const a = new Signal.State(0, {
  [Signal.subtle.watched]: () => {
    console.log(Signal.subtle.introspectSinks(a))
    console.log(Signal.subtle.introspectSources(watcher))
  },
})

watcher = new Signal.subtle.Watcher(() => {
  console.log("notified")
});
watcher.watch(a);

Inside the watched callback, a is reported as having no sinks, but watcher does have a as a source – a visibly inconsistent state.

@littledan
Copy link
Member

This could be solved either way, by updating both before the callback or both after. I have no opinion on the options.

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