Created
March 29, 2018 05:49
-
-
Save noyesa/4109d55cf8db7e911c7257c1c8d95f38 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 injectFn from '../utils/inject-fn'; | |
| export default Ember.Component.extend({ | |
| tagName: 'button', | |
| windowAlert: injectFn(), | |
| click() { | |
| const windowAlert = this.get('windowAlert'); | |
| windowAlert('andrew'); | |
| } | |
| }); |
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 windowAlert from '../utils/window-alert'; | |
| import dasherize from '../utils/dasherize'; | |
| const fns = { windowAlert }; | |
| export function initialize(app) { | |
| Object.keys(fns).forEach((fnName) => { | |
| app.register( | |
| `fn:${dasherize(fnName)}`, | |
| fns[fnName], | |
| { instantiate: false } | |
| ); | |
| }); | |
| } | |
| export default { | |
| initialize, | |
| name: 'register-fns' | |
| }; |
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.13.0", | |
| "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.16.2", | |
| "ember-template-compiler": "2.16.2", | |
| "ember-testing": "2.16.2" | |
| }, | |
| "addons": { | |
| "ember-data": "2.16.3" | |
| } | |
| } |
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
| export default function dasherize(s) { | |
| return s.replace(/[A-Z]/, (c, i) => { | |
| const lc = c.toLowerCase(); | |
| return (i === 0) ? lc : `-${lc}`; | |
| }); | |
| } |
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 dasherize from './dasherize'; | |
| export default function injectFn(fnName) { | |
| return Ember.computed(function(propertyName) { | |
| return Ember.getOwner(this).lookup(`fn:${dasherize(fnName || propertyName)}`); | |
| }); | |
| }; |
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
| export default function windowAlert() { | |
| return window.alert(...arguments); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment