You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially, {{#if state}} sets up a "singleBindComputeHandler" for performance reasons. This assumes the events to listen for never changes. It never calls __read. __read adds a bindSet to the stack. As __read is never called, any read observables are added to the top of the bind stack. This is updateCompute's bind stack.
The fix is to probably use can.__clearReading / __addReading around
If a
{{#if}}
block binds to something (ex state in{{#if state}}
) and another computes updates state like:This causes an infinite loop.
The reason is complex.
Essentially,
{{#if state}}
sets up a "singleBindComputeHandler" for performance reasons. This assumes the events to listen for never changes. It never calls __read. __read adds abindSet
to the stack. As __read is never called, any read observables are added to the top of the bind stack. This isupdateCompute
's bind stack.The fix is to probably use can.__clearReading / __addReading around
https://github.com/bitovi/canjs/blob/master/compute/compute.js#L235
Or, if that damages performance, to simply push a dummy object on the stack and remove it manually.
This will read
The reason is that
{{#if}}
creates a compute and reads from itIt's possible for a compute function to set a value which will cause an infinite loop.
For example, something like:
Essentially, when c2 sets
count
, this will immediately update c1. This will fire an update ofc1
which readsThe text was updated successfully, but these errors were encountered: