2

I am using knockoutjs 2.0 & the knockout-deferred-updates plugin. I am encountering sporadic null object reference errors in my bindings, due, presumably, to the timing of evaluating the various callbacks. I am looking for some guidance on how to determine whether (or which) items to set deferredUpdates = false.

As an alternative, I have put in test code in the binding to check if the value obtained from the valueAccessor() call is null; if so, I do not evaluate the binding function. While this might work for update handlers, it doesn't seem like a good idea for init ones.

Thoughts?

Thanks in advance,

Gene

Gene Golovchinsky
  • 6,101
  • 7
  • 53
  • 81
  • 1
    I'm having the same issues too. I tried putting .extend({ throttle: 500 }); to see if that solves your issues.. it did with me but I'm not happy with that.. I'm still trying to figure out that deferred updates plugin. – Ryan Apr 11 '12 at 01:44
  • I don't know if this is relevant, but recently I ran into these problems much more frequently when running on a slower network. My sense is that because the timing of responses from the server changed, the various event handlers in knockoutjs and the deferred updates plugin where firing in a different sequence than when I am at home, and that revealed some problems. This is just a guess, however. – Gene Golovchinsky Apr 11 '12 at 18:44

1 Answers1

0

Obviously any problem that happens sporadically is difficult to solve, but if it does appear to be caused by slower network response, you can try simulating a slow connection to be able to reproduce the problem more consistently. That should let you debug it better (or at least narrow down the problem).

Community
  • 1
  • 1
Michael Best
  • 16,623
  • 1
  • 37
  • 70
  • Yeah, that sounds like a good tack to take. Know of any such tools that will work with 64bit Win7? None of the links in the post you site refer to this OS (maybe because it wasn't released yet a the time the answers were written!) – Gene Golovchinsky Apr 29 '12 at 17:34
  • 1
    [Fiddler](http://www.fiddler2.com/fiddler2/) might work for you. It was mentioned in [one of the answers](http://stackoverflow.com/a/3330197/1287183). – Michael Best Apr 30 '12 at 10:02
  • Also, if you aren't using the latest version of the deferred updates plugin, please try it to see if it makes a difference. – Michael Best May 01 '12 at 20:16
  • Sorry -- been away at a conference -- will get back to this next week! – Gene Golovchinsky May 11 '12 at 16:06
  • 1
    Great. I also suggest trying the latest version of Knockout, 2.1, that was released recently. – Michael Best May 15 '12 at 01:38
  • Yes, I did upgradate to that, and it did fix some other problems I was seeing. I will need to test this to see if the sporadic problems went away as well. – Gene Golovchinsky May 15 '12 at 02:41