Skip to content

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

@divdavem

Description

@divdavem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions