hybridsjs/hybrids

lagging update glitch

Qsppl opened this issue · 2 comments

example: https://codepen.io/qsppl/pen/WNqXLGO

The observed behavior is not obvious. The first time library users encounter this behavior, it will be confusing.

You must not use setters inside of the value function - as may create an endless loop of actions. You should use the observe method, to take action when one property change should influence another.

However, thanks for pointing it out, I made a fix and released a new version, which will throw for your example code.

Instead of setting a value while getting another, you should use observe:

{
  one: {
    value: 0,
    observe: (host, value) => { host.two = value },
  },
  two: 0,
}

Thank you, now it has become much easier to notice the error and understand why it occurred.