Skip to content

Instantly share code, notes, and snippets.

@chriskrycho
Last active January 23, 2017 19:58
Show Gist options
  • Save chriskrycho/a0e82c43f8b88568f7be3166e816f9d5 to your computer and use it in GitHub Desktop.
Save chriskrycho/a0e82c43f8b88568f7be3166e816f9d5 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
const { Component, RSVP } = Ember;
export default Component.extend({
actions: {
doFoo(bar) {
return RSVP.resolve(bar).finally(() => {
console.log(`did foo with bar ${bar} in A`);
});
}
}
});
import Ember from 'ember';
const { Component, get } = Ember;
export default Component.extend({
actions: {
doQuux(bar) {
get(this, 'onDoFoo')(bar).finally(() => {
console.log(`did quux with bar ${bar} in B by calling onDoFoo`)
});
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
{{component-a}}
<h2>Component A</h2>
{{component-b onDoFoo=(action 'doFoo')}}
<h3>Component B</h3>
<button {{action (action 'doQuux' 42) on='click'}}>Click me!</button>
{
"version": "0.11.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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment