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

Polyfill bug: calling watcher.watch on computed signal (before its latest value is computed) can prevent from getting its correct latest value afterward #216

Open
divdavem opened this issue Apr 30, 2024 · 0 comments

Comments

@divdavem
Copy link

Hello,

I have come across the following bug with the current polyfill implementation (0.1.0): if I call watcher.watch with a computed signal before reading its most up-to-date value, I can no longer get its correct up-to-date value:

  const signal = new Signal.State(0);
  const computedSignal = new Signal.Computed(() => signal.get());
  const watcher = new Signal.subtle.Watcher(() => {});
  expect(computedSignal.get()).toBe(0);
  signal.set(1); // let's update the signal on which computedSignal depends
  watcher.watch(computedSignal); // if this line is removed, the expectation on the following line is successful
  expect(computedSignal.get()).toBe(1); // this expectation fails with current polyfill implementation
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

1 participant