Last active
July 22, 2016 19:56
-
-
Save dfreeman/52f509ae4b40cab8b90b3ab5cd287dc7 to your computer and use it in GitHub Desktop.
elmbery
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 hbs from 'htmlbars-inline-precompile'; | |
| import component from 'twiddle/utils/component'; | |
| const view = hbs` | |
| <button onclick={{action 'update' 'decrement'}}>-</button> | |
| <div>{{model}}</div> | |
| <button onclick={{action 'update' 'increment'}}>+</button> | |
| `; | |
| function update(message, model) { | |
| if (message === 'increment') { | |
| return model + 1; | |
| } else if (message === 'decrement') { | |
| return model - 1; | |
| } | |
| } | |
| export default component({ view, update }); |
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.1", | |
| "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.0", | |
| "ember-data": "2.6.1", | |
| "ember-template-compiler": "2.6.0" | |
| }, | |
| "addons": {} | |
| } |
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 function component({ view, update }) { | |
| return ElmyComponent.extend({ update, layout: view }); | |
| } | |
| const ElmyComponent = Ember.Component.extend({ | |
| actions: { | |
| update(message) { | |
| const update = this.get('update'); | |
| this.set('model', update(message, this.get('model'))); | |
| } | |
| } | |
| }).reopenClass({ | |
| positionalParams: ['model'] | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment