I am using _.bindAll in lots of my Backbone.Views.
_.bindAll(this, 'render', 'addOne', 'addAll', 'someFunctionA', 'someFunctionB');
While refactoring this becomes quite tedious as I need to keep the views methods and the name listings in sync. Both ways this often leads to simple errors.
As there is a short version of bindAll, which would eliminate this need, I am wondering what drawbacks (performance, readability, flexibility, ..) do exist and do you consider them acceptable to gain a bit of a productivity boost.
_.bindAll(this);
There is no practical performance penalty for using that form of bindAll. However, it will be a pain if you do not want a method bound to
thisfor some reason.However, you may find that you do not need to use bindAll as often as you think. All methods that are bound to event handlers (with the events hash) are automatically bound to
this.Also, when you are explicitly binding an event, you can pass the
thisbinding in the third param. For example:this.model.bind('change', this.render, this)