Closed wcjohnson closed 7 years ago
I think this is the best way to go from a readability standpoint, however, it will only be possible if the new TC39 decorators (with finisher support) make it into the standard. Babel hasn't even implemented these yet so that is probably not a good sign. If they do, though, this would be pretty neat:
class MyComponent extends ReduxComponent
# selectors
@selector
getSomeStuff: (state) -> state.stuff
@selector({memoized: true})
getSomeComplicatedStuff: (state) -> longCalculation(state.stuff)
# action creators
@action
update: (newStuff) -> { type: @MODIFY_STUFF, payload: newStuff }
# (this would create an action dispatcher `this.doUpdateMore`
@action({withDispatcherWithPrefix: 'do'})
updateMore: (moreStuff) -> {type: @MODIFY_MORE_STUFF, payload: moreStuff }
The 0.4.x branch implements this functionality completely, including decorators, using the transform-decorators-legacy
Babel transform.
Now that CoffeeScript 2.0 is available, and we're on the Babel toolchain, we can deliver proper support for ES6 classes by analogy with the react model. Something like:
Problems will arise (as they do with React) in things like magic-binding functions. We will also need an API for doing the magic we do with selectors and actionCreators right now.