Skip to content

Instantly share code, notes, and snippets.

@mixonic
Created March 25, 2019 17:17
Show Gist options
  • Save mixonic/c79ee11b7314a6380f7073dd1a15252f to your computer and use it in GitHub Desktop.
Save mixonic/c79ee11b7314a6380f7073dd1a15252f to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
log: Ember.computed(() => []),
open() {
this.get('log').pushObject('opened!');
},
didInsertElement() {
if (this.didInsertCallback) {
this.sendAction('didInsertCallback', this);
}
},
willDestroyElement() {
if (this.willDestroyCallback) {
this.sendAction('willDestroyCallback', this);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
click() {
this._child.open();
},
actions: {
didInsertCallback(child) {
this._child = child;
},
willDestroyCallback(child) {
this._child = null;
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{wrap-component}}
<br>
<br>
{{#each log as |line|}}
<p>{{line}}</p>
{{/each}}
<h3>Great wrapped content</h3>
{{inner-component didInsertCallback="didInsertCallback" willDestroyCallback="willDestroyCallback"}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment