Subscribing "beforeChange" to dependOfferable creates unwanted dependencies

When using a subscription with "beforeChange" on a dependentService, it will create dependencies on any observables included in the callback, as this happens during dependency discovery.

For example, comparing the current value with the previous value in the handler will result in infinite recursion because it will depend on itself.

Anyway, around? Is this expected? It sounds like intuition. Looking at the code, it seems like the event can be easily triggered outside of dependency detection.

thank

+3


source to share


1 answer


There is already an issue on Github for this already: https://github.com/SteveSanderson/knockout/issues/341

Hopefully we can get it soon.



You can now choose your subscription code setTimeout(function() { //your code here }, 0)

to run immediately after the current execution completes, which may or may not work for your scenario.

+3


source







All Articles