Skip to content

Instantly share code, notes, and snippets.

@mixonic
Created March 25, 2019 17:17
Show Gist options
  • Select an option

  • Save mixonic/c79ee11b7314a6380f7073dd1a15252f to your computer and use it in GitHub Desktop.

Select an option

Save mixonic/c79ee11b7314a6380f7073dd1a15252f to your computer and use it in GitHub Desktop.

Revisions

  1. mixonic created this gist Mar 25, 2019.
    21 changes: 21 additions & 0 deletions components.inner-component.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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);
    }
    }
    });
    18 changes: 18 additions & 0 deletions components.wrap-component.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import Ember from 'ember';

    export default Ember.Component.extend({

    click() {
    this._child.open();
    },

    actions: {
    didInsertCallback(child) {
    this._child = child;
    },
    willDestroyCallback(child) {
    this._child = null;
    }
    }

    });
    5 changes: 5 additions & 0 deletions controllers.application.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import Ember from 'ember';

    export default Ember.Controller.extend({
    appName: 'Ember Twiddle'
    });
    6 changes: 6 additions & 0 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    <h1>Welcome to {{appName}}</h1>
    <br>
    <br>
    {{wrap-component}}
    <br>
    <br>
    3 changes: 3 additions & 0 deletions templates.components.inner-component.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    {{#each log as |line|}}
    <p>{{line}}</p>
    {{/each}}
    2 changes: 2 additions & 0 deletions templates.components.wrap-component.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <h3>Great wrapped content</h3>
    {{inner-component didInsertCallback="didInsertCallback" willDestroyCallback="willDestroyCallback"}}
    19 changes: 19 additions & 0 deletions twiddle.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    {
    "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"
    }
    }