documentcloud/backbone — pull request #1903 by gsamokovarov (2012-12-11 23:02:59+00:00)
Title: Add View#listening

Now that there are `Event#listenTo` and `Event#stopListening` I think that this is a great addition next to `View#events`. You can use `View#listening` to declaratively specify object listeners.

```javascript
var View = Backbone.View.extend({
listening: {
model: {'change': 'modelChange'},
eventable: {'custom': 'eventableCustom'}
},

initialize: function() {
this.eventable = _.extend({}, Backbone.Events);
},

modelChange: function() { /* Do whatever... */ },
eventableCustom: function() { /* Do whatever... */ }
}
```

And it will listen to both the passed `model` and the custom `eventable` object and with `stopListening` being called in `View#remove` the implementation is quite simple, as we don't have to unbind the events explicitly. I think that binding events is the most common thing to do in `initialize`, so this may strip-down them a bit.

Just throwing out the idea out there, if you think that now something like this can live in master.