code11 / engine

A declarative state management system
MIT License
9 stars 11 forks source link

Storing an ArrayBuffer doesn't get retrigger when setting a new value #104

Open dumconstantin opened 3 years ago

dumconstantin commented 3 years ago

Producer b is only called once:

const a: producer = ({ foo = update.value }) => {
  const int32 = new Int32Array(2);
  int32[0] = 42;
  foo.set(int32);
  setTimeout(() => {
    int32[1] = 43;
    foo.set(int32);
  });
};
const b: producer = ({ foo = observe.value}) => {
  console.log("foo is", foo);
};

But first setting the value to null and then async setting it to the next array buffer value, the b producer is called twice as it should:

const a: producer = ({ foo = update.value }) => {
  const int32 = new Int32Array(2);
  int32[0] = 42;
  foo.set(int32);
  setTimeout(() => {
    int32[1] = 43;
    foo.set(null);
    setTimeout(() => {
      foo.set(int32);
    })
  });
};

This has to do with the comparison logic as I've tested with different values in the buffer/different buffers and it still doesn't retrigger on update.