Say I have something like a button with an action, and the action has a cell whose value is used when the action is executed by clicking the button.
If I create the button in a bind, and the cell in the action is also made with a bind, but during the calculation to create the button the cell for the action is never actually read, then no listeners will be attached to the cell for the action, and the cell will therefore not update itself to underlying changes.
Now sometime later I click the button, but the cell for the action has an expired value, what happens?
I guess my question is, what happens when the reading of a cell value only happens outside the evaluation of binds?
One solution could be to always add a listener to new reactive cells created during a bind, another solution is simply to evaluate a cell everytime it's value is requested when it has no listeners added.
Ahh, you're putting the entire UI in binds. That's a really clever way to handle the lifecycle of the listeners!
bind is "stupid" in the way that it completely recalculates a cells value on any change of a cell it's previous calculation depended on. It doesn't "understand" the calculation in a way to only recalculate the part that was strictly needed to update its value to a change.
I mention this because if the entire UI is in a bind, then on every change the entire UI would be recreated. I worry that this could get prohibitively slow on a sufficiently complex UI? (It can also lead to problems with widgets losing focus, but that can be solved in a similar way as in Immediate Mode GUI's).
Thanks for the explanation in the link. The problem that is described in the link is clearly solvable, however what I'm referring to is more fundamental.
I'm not talking about nested binds, but just a simple bind such as "z = bind -> x.get() + y.get()". This will add listeners to x and y. When will those listeners be removed again (without adding new ones during the recalculation of z's new value in case of a change to x or y)?
It may be that x and y are the basic models in my app, and during my clicking around in the application I create and close many panels, and each panel has bind-operations that add listeners to x and y. Now the panels may be long gone, and will never be used again, but when will the listeners that was added to x and y as part of creating the panels be removed?
"z = bind -> x.get() + y.get()" seems nice, but when are the attached listeners removed again?
Typically this is solved with weak listeners, but Javascript doesn't support weak references. I'm worried that this library never removes the listeners, effectively leaking like crazy?
Say I have something like a button with an action, and the action has a cell whose value is used when the action is executed by clicking the button.
If I create the button in a bind, and the cell in the action is also made with a bind, but during the calculation to create the button the cell for the action is never actually read, then no listeners will be attached to the cell for the action, and the cell will therefore not update itself to underlying changes.
Now sometime later I click the button, but the cell for the action has an expired value, what happens?
I guess my question is, what happens when the reading of a cell value only happens outside the evaluation of binds?
One solution could be to always add a listener to new reactive cells created during a bind, another solution is simply to evaluate a cell everytime it's value is requested when it has no listeners added.