Skip to content

Instantly share code, notes, and snippets.

@DingoEatingFuzz
Created March 1, 2016 00:06
Show Gist options
  • Save DingoEatingFuzz/0018c429f33e9585202d to your computer and use it in GitHub Desktop.
Save DingoEatingFuzz/0018c429f33e9585202d to your computer and use it in GitHub Desktop.
Reduced Computed Woes
import Ember from 'ember';
export default Ember.Component.extend({
isShowing: false,
actions: {
toggle: function() {
this.toggleProperty('isShowing');
},
emit: function() {
this.sendAction('action');
}
}
});
<button {{action "toggle"}}>Click One</button>
{{#if isShowing}}
<button {{action "emit"}}>Click Two</button>
{{/if}}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
blah: 1,
stuff: function() {
console.log('updating!');
return 'a b c d e'.w();
}.property('blah'),
actions: {
update: function() {
this.incrementProperty('blah');
}
}
});
{{#each stuff as |hmm|}}
<p>{{hmm}} {{a-widget action="update"}}</p>
{{/each}}
Total: {{blah}}
{
"version": "0.6.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.13.13",
"ember-data": "1.13.15",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment