2 ms·
Just one last question... 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 click
by madzanderzen 13y ago
Just one last question...
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.
- xyzzyrz 13y agoThink of cells (including binds) as just containers: when you call .get() (inside or outside a bind), you just get the currently stored value. Besides the container abstraction for its own sake, values also enable the scoping effect described earlier - if you have x.get() + y.get(), and x updates, you don't need to re-evaluate y (which in turn may be a bind - its body is scoped off so that you're not re-evaluating an entire sub-graph of the application). They're also necessary groundwork for smarter propagation strategies, e.g. stopping propagation if the value hasn't changed.