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.
[ Parent
| on HN ]
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.
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.