Skip to content

Instantly share code, notes, and snippets.

@seanjohnson08
Created September 7, 2016 03:53
Show Gist options
  • Select an option

  • Save seanjohnson08/714f4b4f0816513655bb255c533cdeb8 to your computer and use it in GitHub Desktop.

Select an option

Save seanjohnson08/714f4b4f0816513655bb255c533cdeb8 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
// utterly disgusting
classicAction() {
this.sendAction('classicAction', 'four');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
// utterly disgusting
classicAction(...args) {
this.sendAction('classicAction', 'one', ...args);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
// utterly disgusting
classicAction(...args) {
this.sendAction('classicAction', ...args);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
// utterly disgusting
classicAction(...args) {
this.sendAction('classicAction', ...args);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
closureAction(...args) {
alert('Closure action fired! Args: ' + args.join(''));
},
classicAction(...args) {
alert('Classic action fired! Args: ' + args.join(''));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{top-level-component}}
<br>
<br>
{{!-- We have arrived! Fire off each action with an argument. --}}
<button {{action closureAction "four"}}>
Fire Closure Action
</button>
<button {{action classicAction "four"}}>
Fire Classic Action
</button>
{{!--
This first level component needs to do some decorating for some reason. It needs to provide additional arguments to each action.
Closure actions allow for the decorating to happen here.
Classic actions have to do this in the JS layer.
--}}
{{nested-two
closureAction=(action closureAction "one")
classicAction=classicAction}}
{{!--
These next two are passthroughs.
--}}
{{nested-four
classicAction=classicAction
closureAction=closureAction}}
{{!--
These next two are passthroughs.
--}}
{{nested-three
classicAction=classicAction
closureAction=closureAction}}
{{!-- Our journey begins. --}}
{{nested-one
closureAction=(action "closureAction")
classicAction="classicAction"}}
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment