A while ago I asked this question about how to defer updates to an ko.observableArray when doing batch updates, and the answer was to update the wrapped array and then trigger updates with a valueHasMutated call.
Is there an equivalent approach for deferring updates to a ko.observable()? I am finding a lot of time is spent updating and re-updating the dependencies when I update a bunch of data. Is there a good pattern for batching such updates?
Gene
A couple of thoughts in this area:
there is a plugin that makes related updates more efficient: https://github.com/mbest/knockout-deferred-updates. The author Michael Best is now involved with the KO project and has been helping us make some performance improvements. This plugin may eventually get rolled into KO core in some form. You should try this plugin and see how your app performs with it, as it will give us more evidence in the need for these type of changes.
the other method would be similar to something that I wrote about a while back here. Basically, your ko.computed properties have an extra dependency on an observable that you can toggle on and off. When it is on, the ko.computed would do the actual evaluation (which would potentially create many dependencies). When it is off, it would just return the most recent result and drop all of its dependencies other than the flag. When you toggle it back on, then it would get re-evaluated again. During heavy updates, you can pause until the updates are complete.