News for hackers. Stuff that matters.
Re:Rate-limiting JavaScript function calls by pyrotechnick on Monday October 15, 2012 @01:46PM (#4656176)
Re:Rate-limiting JavaScript function calls by jashkenas on Monday October 15, 2012 @02:16PM (#4656354)
The current implementation of Underscore's debounce and throttle functions (both useful) is available here:

https://github.com/documentcloud/underscore/blob/master/unde...

Re:Rate-limiting JavaScript function calls by rthprog on Monday October 15, 2012 @02:20PM (#4656372)
OP here.

I updated the post with a link to underscore's annotated source for debounce and throttle. Thanks for the tip.

Re:Rate-limiting JavaScript function calls by bicknergseng on Monday October 15, 2012 @02:31PM (#4656428)
Had no idea _ had debounce. Just wrote my own the other day... in CoffeeScript no less. Thanks for being awesome!
Re:Rate-limiting JavaScript function calls by gliese1337 on Monday October 15, 2012 @01:51PM (#4656216)
And if you don't want to add dependency on a whole framework just for that little bit of functionality? It's useful to know how to implement it on its own.
Re:Rate-limiting JavaScript function calls by vmind on Monday October 15, 2012 @02:01PM (#4656268)
Well the example given is bugged, as if you make updates at 0 and 50, then it never fires the function at 100 for the change that occurred at 50. If I didn't want to rely on the whole framework, I'd copy and paste the tested implementation (and dependencies) in underscore.

Not that it's bad to know how to do it yourself, but I'd make sure my implementation was sound before sharing it as advice.

Re:Rate-limiting JavaScript function calls by WiseWeasel on Monday October 15, 2012 @02:12PM (#4656332)
Underscore is tiny, and there are lots of other goodies you'll probably want to use in there if you look, like _.each(), _.defer(), _.pluck(), _.escape(), and so many more; totally worth it. I installed underscore for backbone, and I have a hard time imagining life without it now, even if I didn't use backbone.
Re:Rate-limiting JavaScript function calls by dagw on Monday October 15, 2012 @03:58PM (#4656881)
When I'm writing actual web sites I always include underscore. However when writing libraries that I want to distribute on their own I don't want to force unnecessary third party dependencies on end users if it can be avoided. In those cases I have pulled out a single underscores function that I happened to need.