Is there any possibility to wait until all throttled computed observables in a ViewModel are evaluated.
I have a heavy ViewModel with a lot of such observables. And sometimes I need to get it's plain JS representation right after populating it from JSON, but when I try to do that some observables are not evaluated yet.
I have tried to implement a kind of async toJS
, but it doesn't work as expected. Am I doing something wrong there or it's not possible at all?
toJSasync = function (vm) {
var deferred = $.Deferred(),
waiter = ko.computed(function () {
return ko.toJS(vm);
});
deferred.resolve( waiter() );
deferred.always(function () {
waiter.dispose();
});
return deferred.promise();
}