Last active
October 15, 2016 18:44
-
-
Save toranb/53382b373fcf77d16c2cd31226f09ba4 to your computer and use it in GitHub Desktop.
New Twiddle
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 { | |
| number: state.number | |
| }; | |
| }; | |
| var dispatchToActions = (dispatch) => { | |
| return { | |
| add: () => dispatch({type: 'ADD'}) | |
| }; | |
| }; | |
| var NumbersComponent = Ember.Component.extend({ | |
| layout: hbs` | |
| {{number}} | |
| <button onclick={{action "add"}}>add</button> | |
| ` | |
| }); | |
| export default connect(stateToComputed, dispatchToActions)(NumbersComponent); |
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'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
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 createSagaMiddleWare from 'redux-saga'; | |
| import addAsync from '../sagas/counter'; | |
| const createSaga = createSagaMiddleWare.default ? createSagaMiddleWare.default : createSagaMiddleWare; | |
| const sagaMiddleware = createSaga(); | |
| const setup = () => { | |
| sagaMiddleware.run(addAsync); | |
| }; | |
| export default { | |
| middleware: [sagaMiddleware], | |
| setup: setup | |
| }; |
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
| var number = ((state, action) => { | |
| if(action.type === 'INCREMENT') { | |
| return state + 1; | |
| } | |
| return state || 0; | |
| }); | |
| export default { | |
| number | |
| } |
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 saga from 'redux-saga'; | |
| import effects from 'redux-saga'; | |
| const { takeEvery } = saga; | |
| const { call, put } = effects; | |
| const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
| function* incrementAsync() { | |
| yield call(delay, 0); | |
| yield put({type: 'INCREMENT'}); | |
| }; | |
| export default function* addAsync() { | |
| yield* takeEvery('ADD', incrementAsync); | |
| } |
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
| { | |
| "version": "0.10.5", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "2.6.2", | |
| "ember-data": "2.8.0", | |
| "ember-template-compiler": "2.6.2" | |
| }, | |
| "addons": { | |
| "ember-redux": "1.7.0", | |
| "ember-redux-saga-shim": "0.0.8", | |
| "ember-maybe-import-regenerator": "0.1.4" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment