top | item 7162710

(no title)

ghostdiver | 12 years ago

It forces programmer to make few more steps during debugging process, using conditional breakpoints in particular.

not a big deal to put conditional breakpoint in handleStreamEvent whereever it is, but in long run it just a waste of time.

  this.setup = function () {
    this.on('tweet', this.handleStreamEvent.bind(this, 'tweet'));
    this.on('retweet', this.handleStreamEvent.bind(this, 'retweet'));
  };
This pattern will be obsolote as soon as arrow function gets implemented by all major browsers:

  this.setup = function () {
    this.on('tweet', () => this.handleStreamEvent('tweet'));
    this.on('retweet', () => this.handleStreamEvent('retweet'));
  };

discuss

order

ch0wn|12 years ago

Those are not equivalent. You still have to pass on the parameters:

    this.setup = function () {
      this.on('tweet', (e, data) => this.handleStreamEvent('tweet', e, data));
      this.on('retweet', (e, data) => this.handleStreamEvent('retweet', e, data));
    };

ianstormtaylor|12 years ago

Good catch. Once they are added though, it feels a lot more readable than the "bind" alternative.