knockout-deferred-updates
knockout-deferred-updates copied to clipboard
Getting TypeError: currentFrame.callback is not a function
Hello
I'm getting the error below when using the library on my page.
Line 347: currentFrame.callback(subscribable, subscribable._id || (subscribable._id = getId()));
I am using knockout 3.3 (get the error in 3.2 as well) with the ko.mapping and ko.postbox libraries.
Apart from loading the script all i am doing is including the line:
ko.computed.deferUpdates = false;
immediately after the script and then defering updates on an observable arrary further down the line , loading some data and then taking off defered updares again.
self.items.data.deferUpdates = false;
...load some data into self.items.data
self.items.data.deferUpdates = true;
the defered updates to self.items.data seem to be working but the error is preventing other ko page elements working.
thanks
Ross
Some more info...
I am using ko.pureComputed and changed back to ko.computed to see if this had any effect.
When i did this i got the error 2 twice and the page elements for self.items.data did not load.
I have checked out other scripts that i am loading (legacy ko widget libraries i have developed) and changed ko.computed to ko.pureComputed.
This resolves the issue and i am getting no errors on the page.
So ko.computed cannot be used with this plugin then?
thanks Ross
From your description, I'm not sure where the problem is coming from. Is it possible for you to put together an example of the failure?
Hello Michael
Unfortunately the page i have developed is pretty complex with loads and loads of view models loaded and a large library of code supporting them.
All i can tell you is that using ko.pureComputed instead of ko.computed in all of my knockout view models has resolved the issue. I was unable to debug and identify the exact piece of my code that was responsible.
By the way this library has definately given the page a cleaner look when loading and speeded things up...thanks very much!!!!
cheers Ross
I get the same error, it could be related to the mapping plugin. I've also got quite a complex page but I stumbled upon this one when I added something like:
this.modelProp = ko.mapping.fromJS(anArray, {
create: function(value) {
var vm = ko.mapping.fromJS(value)
vm.obs = ko.observable('foo');
vm.comp = ko.computed(function() {
return ["foo"];
});
return vm;
}
});
I get the error when using the 'comp' computed in the page bindings (but not with the 'obs' observable).
Logging the currentFrame just before the error indicates that this could be a minification issue. Most of them have human readable properties like 'callback', 'computed' etc. But, the one causing the error have minified property names like 'Ca', 'La' and 'w'...