次の概念を大まかに達成するための良い方法はありますか?
var computed = ko.computed(function() {
readSomeObservables(); //<-- if these change, notify computed
ko.stopCollectingDependencies();
readSomeMoreObservables(); //<-- if these change, do not notify computed
ko.resumeCollectingDependencies();
});
私は知っていますpeek()
が、この場合、計算は外部モジュールから提供されたメソッドを呼び出します。設計では、これらのメソッドにオブザーバブルが含まれる場合、純粋に偶発的なものである必要があります。
私には1つの解決策があります。それは、大まかにこれを行うことです。
window.setTimeout(function() {
readSomeMoreObservables();
}, 0);
しかし、明らかな理由から、それはほとんど理想的ではなく、状況によっては望ましくない動作につながります。