Skip to content

Instantly share code, notes, and snippets.

@paddyobrien
Last active June 23, 2016 21:25
Show Gist options
  • Save paddyobrien/649cf9fc96096b124612e30a9f50d279 to your computer and use it in GitHub Desktop.
Save paddyobrien/649cf9fc96096b124612e30a9f50d279 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
toggle() {
this.incrementProperty('someState');
this.toggleProperty('isActive');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
wasCleared: false,
thingsChanged: Em.observer('someState', function() {
console.log('observer fired');
if (!this.get('isActive')) {
this.set('things', []);
this.set('wasCleared', true);
}
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isActive: true,
things: [1, 2, 3],
someState: 0
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-component isActive=isActive someState=someState}}
Number of things: {{things.length}}<br />
{{#if isActive}}
{{my-other-component isActive=isActive things=things someState=someState}}
{{/if}}
<br>
<br>
<button {{action 'toggle'}}>Clear things</button>
{{yield}}
Number of things inside {{things.length}}<br />
Was cleared: {{wasCleared}}
{
"version": "0.9.3",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.12.2",
"ember-data": "2.6.1",
"ember-template-compiler": "1.12.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment