documentcloud/backbone — Issue #1020: underscore's throttle and debounce as options when declaring view events?
Author: mreinstein
Created: 2012-02-17 07:47:43+00:00
State: open

I love underscore's throttle and debounce capabilities. I would also love to be able to automatically hook up the behaviors when declaring events in my Backbone views, rather than manually handling the plumbing for these events in my initialize functions.s

I'm not sure exactly how the synax would look, maybe something like this:

events: {
'resize window throttle 300': 'window_resize_func'
'keydown #mytext debounce 500': 'reposition_elements_func'
.
.
}

Maybe there is a more elegant syntax to express this in, open for suggestions. I could see this being very handy for just about anyone that handles voluminous event types like mouse move, window resize, etc.

I'm not sure if this has already been discussed so if I'm exhuming an old conversation my apologies.