mbest / knockout-deferred-updates

Deferred Updates plugin for Knockout <=3.3.0
http://mbest.github.io/knockout-deferred-updates/
134 stars 23 forks source link

Getting TypeError: currentFrame.callback is not a function #30

Open roscopeeco opened 9 years ago

roscopeeco commented 9 years ago

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

roscopeeco commented 9 years ago

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.

roscopeeco commented 9 years ago

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

mbest commented 9 years ago

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?

roscopeeco commented 9 years ago

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

JohanAhlen commented 8 years ago

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'...