The-M-Project icon indicating copy to clipboard operation
The-M-Project copied to clipboard

Syntactial change to bind multiple events to one handler

Open sebastianwerler opened this issue 12 years ago • 1 comments

Right now, if you want to have different event types being bound to one handler, you have to write duplicated code like this:

events: {
  tap: {
   target: MyApp.MyController,
   action: 'doSomething'
  },
  click: {
   target: MyApp.MyController,
   action: 'doSomething'
  },
}

It would be nice to have the opportunity to avoid this code duplication and write something like this as an alternative form of event binding:

events: {
  types: ['click', 'tap'],
  handler: {
    target: MyApp.MyController,
    action: 'doSomething'
  }
}

I'm looking forward to your opinions about it.

sebastianwerler avatar Jul 16 '12 07:07 sebastianwerler

It is DRYer.

stephentcannon avatar Jul 16 '12 18:07 stephentcannon