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

watched callback calling .unwatch #206

Open
prophile opened this issue Apr 29, 2024 · 0 comments · May be fixed by #223
Open

watched callback calling .unwatch #206

prophile opened this issue Apr 29, 2024 · 0 comments · May be fixed by #223

Comments

@prophile
Copy link
Contributor

prophile commented Apr 29, 2024

Consider the following code:

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

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

It's not clear from the specification what should happen here and it should probably be spelled out. In the event, the polyfill at f7c550b throws a RangeError from internal code and then leaves an inconsistent state - the watcher has a as a source but a does not have the watcher as a sync, is permissible in how the spec is currently worded but I suspect is not an invariant we want to break here.

@prophile prophile linked a pull request May 15, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant