Last active
December 29, 2018 16:47
-
-
Save toranb/24d755b385aa334fe0bab1259fde29bf to your computer and use it in GitHub Desktop.
es2015 class syntax (ember redux)
This file contains 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 { connect } from 'ember-redux'; | |
import hbs from 'htmlbars-inline-precompile'; | |
const stateToComputed = state => ({ | |
number: state.number | |
}); | |
const dispatchToActions = dispatch => ({ | |
add: () => dispatch({type: 'ADD'}) | |
}); | |
class MyClazz extends Ember.Component { | |
get layout() { | |
return hbs` | |
<div>number: {{number}}</div> | |
<div>color: {{color}}</div> | |
<button onclick={{action "add"}}>add</button> | |
` | |
} | |
constructor() { | |
super(...arguments); | |
this.color = 'blue'; | |
// ember 3.6+ use init instead of constructor | |
// super.init(...arguments); | |
// https://github.com/emberjs/rfcs/pull/337 | |
} | |
} | |
export default connect(stateToComputed, dispatchToActions)(MyClazz); |
This file contains 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'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains 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 { combineReducers } from 'redux'; | |
const number = ((state, action) => { | |
if(action.type === 'ADD') { | |
return state + 1; | |
} | |
return state || 0; | |
}); | |
export default combineReducers({ | |
number | |
}); |
This file contains 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
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-redux": "4.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment