martyjs / marty

A Javascript library for state management in React applications
http://martyjs.org
MIT License
1.09k stars 76 forks source link

Consider reversing order in this.handlers #374

Closed ghost closed 9 years ago

ghost commented 9 years ago

Here is an annoying suggestion ;) Could you consider reversing the order of data we need pass to this.handlers in the store? So instead of this.handlers = {methodName: actionName}, you would write this.handlers = {actionName: this.methodName}. I know it's painful to change this, so maybe a new method could be introduced (e.g. like bindActions in fluxxor).

There are couple of reasons:

I know you will then lose the possibility to bind the same handler to multiple events using an array as a value, but I would rather duplicate the binding for each action.

taion commented 9 years ago

It's recommended to use the @handles decorator anyway if you're using at least Babel stage 1.

ghost commented 9 years ago

@taion Thanks for the cool tip, did not know about this decorator.

taion commented 9 years ago

Well, it's not documented... yet.

Does that work for your use case?

ghost commented 9 years ago

Certainly! Ditching now all my handlers in favor of the new decorator. So I guess my initial ask becomes irrelevant now.