maccman/spine — pull request #216 by vojto (2012-02-27 15:59:25+00:00)
Title: Making delegateEvents state-independent

Suppose you have controller `Form` and a subclass called `NiceForm`.

Currently, if you want to support more events, you have to do this:

constructor: ->
@events['click .nice'] = 'nice'
super

While this API works well, it took me a few minutes to realize I have to set it before super. (Also, in most languages you can't/are not supposed to do anything before super in init, so one wouldn't think of it.)

Setting it **after** super would result in double delegating/handlers being called twice.

Thanks to this change, it will be possible to add events by simply calling @delegateEvents with an argument, like this:

constructor: ->
super
@delegateEvents 'click .nice': 'nice'