Last active
August 11, 2016 05:22
-
-
Save toranb/5c7fcf6c9d10093f9ca9 to your computer and use it in GitHub Desktop.
a FRP ember component using redux (yay)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import hbs from 'htmlbars-inline-precompile'; | |
import connect from 'ember-redux/components/connect'; | |
var stateToComputed = (state) => { | |
return { | |
low: state.low, | |
high: state.high | |
}; | |
}; | |
var dispatchToActions = (dispatch) => { | |
return { | |
up: () => dispatch({type: 'UP'}), | |
down: () => dispatch({type: 'DOWN'}) | |
}; | |
}; | |
var CountListComponent = Ember.Component.extend({ | |
layout: hbs` | |
<span class="parent-state">{{low}}</span> | |
<button class="btn-up" onclick={{action "up"}}>up</button> | |
{{count-detail high=high down=(action "down")}} | |
` | |
}); | |
export default connect(stateToComputed, dispatchToActions)(CountListComponent); |
@bfitch These are great finds. Thanks! They're both great stories of projects adapting new ideas to their own structure and vocabulary and vice-versa. It's clear to me that we're really just at the beginning of this journey, but I'm so looking forward to it.
So who wants to do some elm pair programming with me? It's totallyl the future! http://elm-lang.org
I think most of the smartest nerds have left javascript already.
Also I'm interested in trying to port elm-ui sass to elm. Cut one language out of the picture. Also need to port compass.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cowboyd Thank you for taking the time to respond at length and for clarifying your intent...really appreciate it. I understand were you're coming from much better and am relieved that you don't need to be sold on the value of Flux-y patterns. :)
I am totally on board with your concern to provide the most Ember-like API for these patterns and I agree that API changes should be justified and essential, instead of just ported over. One interesting thing I noticed while working on ember-cerebral was how well it integrates with Ember's existing routes, components, actions, and computed property APIs. The two fit together so well, but it requires learning (and liking) the "other half" of the integration: cerebral.
One interesting case study is vue.js. They introduced pretty much a redux port, but using the current Vue idioms and APIs: http://vuejs.github.io/vuex/en/intro.html.
Sounds like exactly what you (we?!) are advocating.